diff --git a/package.json b/package.json index 614d735e..bc525b38 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "minibits_wallet", - "version": "0.1.11-beta.7", + "version": "0.1.11-beta.8", "private": true, "scripts": { "android:clean": "cd android && ./gradlew clean", diff --git a/src/App.tsx b/src/App.tsx index a35bcace..183e1e2d 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -83,6 +83,10 @@ function App(props: AppProps) { } } + if(userSettingsStore.theme !== userSettingsStore.nextTheme) { + userSettingsStore.setTheme(userSettingsStore.nextTheme) + } + // Set initial websocket to close as it might have remained open on last app close relaysStore.resetStatuses() log.trace('[useInitialRootStore]', 'App is ready to render') diff --git a/src/models/UserSettingsStore.ts b/src/models/UserSettingsStore.ts index 97f9488b..6a218013 100644 --- a/src/models/UserSettingsStore.ts +++ b/src/models/UserSettingsStore.ts @@ -8,6 +8,7 @@ export type UserSettings = { preferredUnit: MintUnit exchangeCurrency: CurrencyCode theme: ThemeCode + nextTheme: ThemeCode isOnboarded: boolean isAuthOn: boolean isLocalBackupOn: boolean @@ -22,6 +23,7 @@ export const UserSettingsStoreModel = types preferredUnit: types.optional(types.frozen(), 'sat'), exchangeCurrency: types.optional(types.frozen(), CurrencyCode.USD), theme: types.optional(types.frozen(), ThemeCode.DEFAULT), + nextTheme: types.optional(types.frozen(), ThemeCode.DEFAULT), isOnboarded: types.optional(types.boolean, false), isAuthOn: types.optional(types.boolean, false), isLocalBackupOn: types.optional(types.boolean, true), @@ -42,6 +44,10 @@ export const UserSettingsStoreModel = types self.theme = theme return theme }, + setNextTheme: (theme: ThemeCode) => { + self.nextTheme = theme + return theme + }, setIsOnboarded: (isOnboarded: boolean) => { self.isOnboarded = isOnboarded return isOnboarded diff --git a/src/screens/SettingsScreen.tsx b/src/screens/SettingsScreen.tsx index ea1436d6..ece31ee3 100644 --- a/src/screens/SettingsScreen.tsx +++ b/src/screens/SettingsScreen.tsx @@ -115,12 +115,9 @@ export const SettingsScreen: FC = observer( log.debug('[useInitialRootStore]', {deviceToken}) - // Make sure profile has already been created (i.e. this is not first run) - if(walletProfileStore.pubkey && deviceToken) { - // if device token changed, update the server - if(deviceToken !== walletProfileStore.device) { - await walletProfileStore.setDevice(deviceToken) - } + if(deviceToken && deviceToken !== walletProfileStore.device) { + // if device token changed, update the server + await walletProfileStore.setDevice(deviceToken) } } catch (e: any) { log.info(e.name, e.message) @@ -243,9 +240,9 @@ export const SettingsScreen: FC = observer( const onSelectTheme = async function(theme: ThemeCode) { if(currentTheme !== theme) { try { - userSettingsStore.setTheme(theme) + userSettingsStore.setNextTheme(theme) setCurrentTheme(theme) - setInfo('Restart the wallet to apply new theme.') + setInfo('Restart the wallet to apply the new theme.') } catch (e: any) { log.warn('[onSelectTheme]', e.message) }