mirror of
https://github.com/minibits-cash/minibits_wallet.git
synced 2026-10-05 19:28:26 +00:00
Fix regression bug: theme change causes app to crash
This commit is contained in:
+1
-1
@@ -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",
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -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<MintUnit>(), 'sat'),
|
||||
exchangeCurrency: types.optional(types.frozen<CurrencyCode | null>(), CurrencyCode.USD),
|
||||
theme: types.optional(types.frozen<ThemeCode>(), ThemeCode.DEFAULT),
|
||||
nextTheme: types.optional(types.frozen<ThemeCode>(), 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
|
||||
|
||||
@@ -115,13 +115,10 @@ export const SettingsScreen: FC<SettingsScreenProps> = observer(
|
||||
|
||||
log.debug('[useInitialRootStore]', {deviceToken})
|
||||
|
||||
// Make sure profile has already been created (i.e. this is not first run)
|
||||
if(walletProfileStore.pubkey && deviceToken) {
|
||||
if(deviceToken && deviceToken !== walletProfileStore.device) {
|
||||
// if device token changed, update the server
|
||||
if(deviceToken !== walletProfileStore.device) {
|
||||
await walletProfileStore.setDevice(deviceToken)
|
||||
}
|
||||
}
|
||||
} catch (e: any) {
|
||||
log.info(e.name, e.message)
|
||||
return false // silent
|
||||
@@ -243,9 +240,9 @@ export const SettingsScreen: FC<SettingsScreenProps> = 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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user