fix: 🐛 Clear specific keys instead of erasing the entire cache

This commit is contained in:
Viktor Sarström 2021-05-10 12:46:07 +02:00
parent 2b99a64730
commit 9e83d8a0f2
2 changed files with 9 additions and 3 deletions

View File

@ -1,5 +1,3 @@
import AsyncStorage from '@react-native-async-storage/async-storage'
import { useApi, useChildList } from '@skolplattformen/api-hooks'
import { Child } from '@skolplattformen/embedded-api'
import {
@ -24,6 +22,7 @@ import {
import { useSafeAreaInsets } from 'react-native-safe-area-context'
import ActionSheet from 'rn-actionsheet-module'
import { Colors, Layout as LayoutStyle, Sizing, Typography } from '../styles'
import { clearCache } from '../utils/cache'
import { translate } from '../utils/translation'
import { ChildListItem } from './childListItem.component'
import { SettingsIcon } from './icon.component'
@ -66,7 +65,7 @@ export const Children = () => {
const logout = () => {
api.logout()
AsyncStorage.clear()
clearCache()
}
// We need to skip safe area view here, due to the reason that it's adding a white border

View File

@ -0,0 +1,7 @@
import AsyncStorage from '@react-native-async-storage/async-storage'
export const keys: Array<string> = ['ssn']
export const clearCache = () => {
AsyncStorage.multiRemove(keys)
}