mirror of
https://github.com/minibits-cash/minibits_wallet.git
synced 2026-10-06 03:38:24 +00:00
Register push token on changing notification settings
This commit is contained in:
+2
-2
@@ -78,8 +78,8 @@ function App(props: AppProps) {
|
||||
log.debug('[useInitialRootStore]', {deviceToken})
|
||||
|
||||
// Save new or refreshed token to local and server profile
|
||||
if (deviceToken.length > 0 && deviceToken !== walletProfileStore.device) {
|
||||
walletProfileStore.setDevice(deviceToken)
|
||||
if (deviceToken.length > 0) {
|
||||
await walletProfileStore.setDevice(deviceToken)
|
||||
}
|
||||
|
||||
// Set initial websocket to close as it might have remained open on last app close
|
||||
|
||||
@@ -257,8 +257,12 @@ export const WalletProfileStoreModel = types
|
||||
return self
|
||||
}),
|
||||
setDevice: flow(function* setDevice(device: string) {
|
||||
self.device = device
|
||||
yield MinibitsClient.updateDeviceToken(self.pubkey, {deviceToken: device})
|
||||
try {
|
||||
yield MinibitsClient.updateDeviceToken(self.pubkey, {deviceToken: device})
|
||||
self.device = device
|
||||
} catch (e: any) {
|
||||
log.error('[setDevice]', e.message)
|
||||
}
|
||||
}),
|
||||
setNip05(nip05: string) { // used in migration to v3 model
|
||||
self.nip05 = nip05
|
||||
|
||||
@@ -89,7 +89,7 @@ export const SettingsScreen: FC<SettingsScreenProps> = observer(
|
||||
log.debug('[SettingsScreen.useEffect]', {deviceToken})
|
||||
|
||||
// Save new or refreshed token to local and server profile
|
||||
if (deviceToken.length > 0 && deviceToken !== walletProfileStore.device) {
|
||||
if (deviceToken.length) {
|
||||
walletProfileStore.setDevice(deviceToken)
|
||||
}
|
||||
} catch (e: any) {
|
||||
|
||||
Reference in New Issue
Block a user