Fix regression bug: theme change causes app to crash

This commit is contained in:
minibits-cash
2025-01-31 13:46:36 +01:00
parent 8b0aa6712b
commit 85c1bdafa4
4 changed files with 16 additions and 9 deletions
+1 -1
View File
@@ -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",
+4
View File
@@ -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')
+6
View File
@@ -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
+5 -8
View File
@@ -115,12 +115,9 @@ 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 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<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)
}