Add dev-only button to clear storage

This commit is contained in:
Eric Bailey
2023-11-20 15:54:10 -06:00
parent 019aae5f01
commit bd061f983e
2 changed files with 22 additions and 0 deletions
+6
View File
@@ -16,3 +16,9 @@ export async function read(): Promise<Schema | undefined> {
return objData return objData
} }
} }
export async function clear() {
await AsyncStorage.removeItem(BSKY_STORAGE, e => {
if (e) console.error(e)
})
}
+16
View File
@@ -64,6 +64,7 @@ import {
import {useProfileQuery} from '#/state/queries/profile' import {useProfileQuery} from '#/state/queries/profile'
import {useClearPreferencesMutation} from '#/state/queries/preferences' import {useClearPreferencesMutation} from '#/state/queries/preferences'
import {useInviteCodesQuery} from '#/state/queries/invites' import {useInviteCodesQuery} from '#/state/queries/invites'
import {clear as clearPersistentData} from '#/state/persisted/store'
// TEMPORARY (APP-700) // TEMPORARY (APP-700)
// remove after backend testing finishes // remove after backend testing finishes
@@ -266,6 +267,11 @@ export const SettingsScreen = withAuthRequired(function Settings({}: Props) {
Linking.openURL(STATUS_PAGE_URL) Linking.openURL(STATUS_PAGE_URL)
}, []) }, [])
const clearAllPersistedData = React.useCallback(async () => {
await clearPersistentData()
Toast.show(`Storage cleared, you need to restart the app now.`)
}, [])
return ( return (
<View style={[s.hContentRegion]} testID="settingsScreen"> <View style={[s.hContentRegion]} testID="settingsScreen">
<ViewHeader title="Settings" /> <ViewHeader title="Settings" />
@@ -671,6 +677,16 @@ export const SettingsScreen = withAuthRequired(function Settings({}: Props) {
<Trans>Reset onboarding state</Trans> <Trans>Reset onboarding state</Trans>
</Text> </Text>
</TouchableOpacity> </TouchableOpacity>
<TouchableOpacity
style={[pal.view, styles.linkCardNoIcon]}
onPress={clearAllPersistedData}
accessibilityRole="button"
accessibilityHint="Clear all storage data"
accessibilityLabel={_(msg`Clear all storage data`)}>
<Text type="lg" style={pal.text}>
<Trans>Clear all storage data (restart after this)</Trans>
</Text>
</TouchableOpacity>
</> </>
) : null} ) : null}
<View style={[styles.footer]}> <View style={[styles.footer]}>