diff --git a/src/state/persisted/legacy.ts b/src/state/persisted/legacy.ts index fefa7f3725..878c05a751 100644 --- a/src/state/persisted/legacy.ts +++ b/src/state/persisted/legacy.ts @@ -128,6 +128,8 @@ export async function migrate() { const newData = transform(legacyData) await write(newData) logger.debug('persisted state: migrated legacy storage') + } else { + logger.debug('persisted state: no migration needed') } } catch (e) { logger.error('persisted state: error migrating legacy storage', { @@ -135,3 +137,9 @@ export async function migrate() { }) } } + +export async function clearLegacyStorage() { + await AsyncStorage.removeItem(DEPRECATED_ROOT_STATE_STORAGE_KEY, e => { + if (e) console.error(e) + }) +} diff --git a/src/view/screens/Settings.tsx b/src/view/screens/Settings.tsx index b414e4c36b..20695a22d9 100644 --- a/src/view/screens/Settings.tsx +++ b/src/view/screens/Settings.tsx @@ -64,7 +64,8 @@ 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' +import {clear as clearStorage} from '#/state/persisted/store' +import {clearLegacyStorage} from '#/state/persisted/legacy' // TEMPORARY (APP-700) // remove after backend testing finishes @@ -267,10 +268,14 @@ export const SettingsScreen = withAuthRequired(function Settings({}: Props) { Linking.openURL(STATUS_PAGE_URL) }, []) - const clearAllPersistedData = React.useCallback(async () => { - await clearPersistentData() + const clearAllStorage = React.useCallback(async () => { + await clearStorage() Toast.show(`Storage cleared, you need to restart the app now.`) }, []) + const clearAllLegacyStorage = React.useCallback(async () => { + await clearLegacyStorage() + Toast.show(`Legacy storage cleared, you need to restart the app now.`) + }, []) return ( @@ -679,7 +684,19 @@ export const SettingsScreen = withAuthRequired(function Settings({}: Props) { + + + Clear all legacy storage data (restart after this) + + + +