From 5d3f773a2a6ea1632101c0445a956b9be135b626 Mon Sep 17 00:00:00 2001 From: xmflsct Date: Wed, 1 Feb 2023 00:06:33 +0100 Subject: [PATCH 1/2] Faster image loading transition --- src/components/Emojis/List.tsx | 2 +- src/components/GracefullyImage.tsx | 8 ++++---- src/screens/Compose/Root/Footer/Attachments.tsx | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/Emojis/List.tsx b/src/components/Emojis/List.tsx index 455a1044..56418778 100644 --- a/src/components/Emojis/List.tsx +++ b/src/components/Emojis/List.tsx @@ -131,7 +131,7 @@ const EmojisList = () => { > {uri.preview && !imageLoaded ? ( ) : null} { setImageLoaded(true) diff --git a/src/screens/Compose/Root/Footer/Attachments.tsx b/src/screens/Compose/Root/Footer/Attachments.tsx index 7743ce1d..b4496616 100644 --- a/src/screens/Compose/Root/Footer/Attachments.tsx +++ b/src/screens/Compose/Root/Footer/Attachments.tsx @@ -106,7 +106,7 @@ const ComposeAttachments: React.FC = ({ accessibleRefAttachments }) => { > Date: Wed, 1 Feb 2023 00:07:38 +0100 Subject: [PATCH 2/2] Catch potentially json parsing error --- src/components/Instance/index.tsx | 2 +- src/utils/storage/actions.ts | 20 ++++++++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) 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 }