From bd061f983ee49ea9e6d7ec8ad1465312e4ff3d6d Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Mon, 20 Nov 2023 15:54:10 -0600 Subject: [PATCH] Add dev-only button to clear storage --- src/state/persisted/store.ts | 6 ++++++ src/view/screens/Settings.tsx | 16 ++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/state/persisted/store.ts b/src/state/persisted/store.ts index 2b03bec20c..e62fb04297 100644 --- a/src/state/persisted/store.ts +++ b/src/state/persisted/store.ts @@ -16,3 +16,9 @@ export async function read(): Promise { return objData } } + +export async function clear() { + await AsyncStorage.removeItem(BSKY_STORAGE, e => { + if (e) console.error(e) + }) +} diff --git a/src/view/screens/Settings.tsx b/src/view/screens/Settings.tsx index 6c61a699b2..b414e4c36b 100644 --- a/src/view/screens/Settings.tsx +++ b/src/view/screens/Settings.tsx @@ -64,6 +64,7 @@ import { import {useProfileQuery} from '#/state/queries/profile' import {useClearPreferencesMutation} from '#/state/queries/preferences' import {useInviteCodesQuery} from '#/state/queries/invites' +import {clear as clearPersistentData} from '#/state/persisted/store' // TEMPORARY (APP-700) // remove after backend testing finishes @@ -266,6 +267,11 @@ export const SettingsScreen = withAuthRequired(function Settings({}: Props) { Linking.openURL(STATUS_PAGE_URL) }, []) + const clearAllPersistedData = React.useCallback(async () => { + await clearPersistentData() + Toast.show(`Storage cleared, you need to restart the app now.`) + }, []) + return ( @@ -671,6 +677,16 @@ export const SettingsScreen = withAuthRequired(function Settings({}: Props) { Reset onboarding state + + + Clear all storage data (restart after this) + + ) : null}