Register push token on changing notification settings

This commit is contained in:
minibits-cash
2024-05-30 10:10:07 +02:00
parent 35ebb006a5
commit f90033dbf6
3 changed files with 9 additions and 5 deletions
+2 -2
View File
@@ -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
+6 -2
View File
@@ -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
+1 -1
View File
@@ -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) {