diff --git a/src/components/Instance/index.tsx b/src/components/Instance/index.tsx index 5aad3b7b..efe90d19 100644 --- a/src/components/Instance/index.tsx +++ b/src/components/Instance/index.tsx @@ -186,7 +186,7 @@ const ComponentInstance: React.FC = ({ if (!account) { setGlobalStorage('accounts', (accounts || []).concat([accountKey])) } - setAccount(accountKey) + await setAccount(accountKey) goBack && navigation.goBack() } diff --git a/src/utils/storage/actions.ts b/src/utils/storage/actions.ts index 602d4407..701219e6 100644 --- a/src/utils/storage/actions.ts +++ b/src/utils/storage/actions.ts @@ -33,9 +33,13 @@ export const getGlobalStorage = { object: (key: T) => { const value = storage.global.getString(key) if (value?.length) { - return JSON.parse(value) as NonNullable extends object - ? StorageGlobal[T] - : never + try { + return JSON.parse(value) as NonNullable extends object + ? StorageGlobal[T] + : never + } catch { + return undefined + } } else { return undefined } @@ -108,9 +112,13 @@ export const getAccountStorage = { object: (key: T) => { const value = storage.account?.getString(key) if (value?.length) { - return JSON.parse(value) as NonNullable extends object - ? StorageAccount[T] - : never + try { + return JSON.parse(value) as NonNullable extends object + ? StorageAccount[T] + : never + } catch { + return undefined + } } else { return undefined }