feat: 🎸 Clear personal cache on login and logout (#572)
Until we have a better cache-clearing function in hooks lib this will help with not filling the phone with old data
This commit is contained in:
parent
933a8840a3
commit
bf29ab58ed
|
@ -34,6 +34,7 @@ import {
|
|||
PersonIcon,
|
||||
SelectIcon,
|
||||
} from './icon.component'
|
||||
import AppStorage from '../services/appStorage'
|
||||
|
||||
const BankId = () => (
|
||||
<Image
|
||||
|
@ -88,6 +89,8 @@ export const Login = () => {
|
|||
] as const
|
||||
|
||||
const loginHandler = async () => {
|
||||
const user = await api.getUser()
|
||||
await AppStorage.clearPersonalData(user)
|
||||
showModal(false)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { NavigationProp, useNavigation } from '@react-navigation/core'
|
||||
import { useApi } from '@skolplattformen/hooks'
|
||||
import { useApi, useUser } from '@skolplattformen/hooks'
|
||||
import React, { useCallback } from 'react'
|
||||
import { ScrollView } from 'react-native'
|
||||
import { NativeStackNavigationOptions } from 'react-native-screens/native-stack'
|
||||
|
@ -28,14 +28,16 @@ export const SettingsScreen = () => {
|
|||
const langCode = LanguageService.getLanguageCode()
|
||||
const language = languages.find((l) => l.langCode === langCode)
|
||||
const { api } = useApi()
|
||||
const { data: user } = useUser()
|
||||
|
||||
const logout = useCallback(async () => {
|
||||
await AppStorage.clearTemporaryItems()
|
||||
await AppStorage.clearPersonalData(user)
|
||||
await api.logout()
|
||||
navigation.reset({
|
||||
routes: [{ name: 'Login' }],
|
||||
})
|
||||
}, [api, navigation])
|
||||
}, [api, navigation, user])
|
||||
|
||||
return (
|
||||
<ScrollView
|
||||
|
|
Loading…
Reference in New Issue