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,
|
PersonIcon,
|
||||||
SelectIcon,
|
SelectIcon,
|
||||||
} from './icon.component'
|
} from './icon.component'
|
||||||
|
import AppStorage from '../services/appStorage'
|
||||||
|
|
||||||
const BankId = () => (
|
const BankId = () => (
|
||||||
<Image
|
<Image
|
||||||
|
@ -88,6 +89,8 @@ export const Login = () => {
|
||||||
] as const
|
] as const
|
||||||
|
|
||||||
const loginHandler = async () => {
|
const loginHandler = async () => {
|
||||||
|
const user = await api.getUser()
|
||||||
|
await AppStorage.clearPersonalData(user)
|
||||||
showModal(false)
|
showModal(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { NavigationProp, useNavigation } from '@react-navigation/core'
|
import { NavigationProp, useNavigation } from '@react-navigation/core'
|
||||||
import { useApi } from '@skolplattformen/hooks'
|
import { useApi, useUser } from '@skolplattformen/hooks'
|
||||||
import React, { useCallback } from 'react'
|
import React, { useCallback } from 'react'
|
||||||
import { ScrollView } from 'react-native'
|
import { ScrollView } from 'react-native'
|
||||||
import { NativeStackNavigationOptions } from 'react-native-screens/native-stack'
|
import { NativeStackNavigationOptions } from 'react-native-screens/native-stack'
|
||||||
|
@ -28,14 +28,16 @@ export const SettingsScreen = () => {
|
||||||
const langCode = LanguageService.getLanguageCode()
|
const langCode = LanguageService.getLanguageCode()
|
||||||
const language = languages.find((l) => l.langCode === langCode)
|
const language = languages.find((l) => l.langCode === langCode)
|
||||||
const { api } = useApi()
|
const { api } = useApi()
|
||||||
|
const { data: user } = useUser()
|
||||||
|
|
||||||
const logout = useCallback(async () => {
|
const logout = useCallback(async () => {
|
||||||
await AppStorage.clearTemporaryItems()
|
await AppStorage.clearTemporaryItems()
|
||||||
|
await AppStorage.clearPersonalData(user)
|
||||||
await api.logout()
|
await api.logout()
|
||||||
navigation.reset({
|
navigation.reset({
|
||||||
routes: [{ name: 'Login' }],
|
routes: [{ name: 'Login' }],
|
||||||
})
|
})
|
||||||
}, [api, navigation])
|
}, [api, navigation, user])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ScrollView
|
<ScrollView
|
||||||
|
|
Loading…
Reference in New Issue