Add legacy storage clearing too
This commit is contained in:
@@ -128,6 +128,8 @@ export async function migrate() {
|
|||||||
const newData = transform(legacyData)
|
const newData = transform(legacyData)
|
||||||
await write(newData)
|
await write(newData)
|
||||||
logger.debug('persisted state: migrated legacy storage')
|
logger.debug('persisted state: migrated legacy storage')
|
||||||
|
} else {
|
||||||
|
logger.debug('persisted state: no migration needed')
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.error('persisted state: error migrating legacy storage', {
|
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)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@@ -64,7 +64,8 @@ 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'
|
import {clear as clearStorage} from '#/state/persisted/store'
|
||||||
|
import {clearLegacyStorage} from '#/state/persisted/legacy'
|
||||||
|
|
||||||
// TEMPORARY (APP-700)
|
// TEMPORARY (APP-700)
|
||||||
// remove after backend testing finishes
|
// remove after backend testing finishes
|
||||||
@@ -267,10 +268,14 @@ export const SettingsScreen = withAuthRequired(function Settings({}: Props) {
|
|||||||
Linking.openURL(STATUS_PAGE_URL)
|
Linking.openURL(STATUS_PAGE_URL)
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
const clearAllPersistedData = React.useCallback(async () => {
|
const clearAllStorage = React.useCallback(async () => {
|
||||||
await clearPersistentData()
|
await clearStorage()
|
||||||
Toast.show(`Storage cleared, you need to restart the app now.`)
|
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 (
|
return (
|
||||||
<View style={[s.hContentRegion]} testID="settingsScreen">
|
<View style={[s.hContentRegion]} testID="settingsScreen">
|
||||||
@@ -679,7 +684,19 @@ export const SettingsScreen = withAuthRequired(function Settings({}: Props) {
|
|||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
style={[pal.view, styles.linkCardNoIcon]}
|
style={[pal.view, styles.linkCardNoIcon]}
|
||||||
onPress={clearAllPersistedData}
|
onPress={clearAllLegacyStorage}
|
||||||
|
accessibilityRole="button"
|
||||||
|
accessibilityHint="Clear all legacy storage data"
|
||||||
|
accessibilityLabel={_(msg`Clear all legacy storage data`)}>
|
||||||
|
<Text type="lg" style={pal.text}>
|
||||||
|
<Trans>
|
||||||
|
Clear all legacy storage data (restart after this)
|
||||||
|
</Trans>
|
||||||
|
</Text>
|
||||||
|
</TouchableOpacity>
|
||||||
|
<TouchableOpacity
|
||||||
|
style={[pal.view, styles.linkCardNoIcon]}
|
||||||
|
onPress={clearAllStorage}
|
||||||
accessibilityRole="button"
|
accessibilityRole="button"
|
||||||
accessibilityHint="Clear all storage data"
|
accessibilityHint="Clear all storage data"
|
||||||
accessibilityLabel={_(msg`Clear all storage data`)}>
|
accessibilityLabel={_(msg`Clear all storage data`)}>
|
||||||
|
|||||||
Reference in New Issue
Block a user