fix(front): clear indexedDB and queue on logout
Part-of: <https://dev.funkwhale.audio/funkwhale/funkwhale/-/merge_requests/2455>
This commit is contained in:
parent
891874dc20
commit
ad7020cb5a
|
@ -0,0 +1 @@
|
||||||
|
Fixed stale data in indexedDB after logout (#2133)
|
|
@ -7,6 +7,9 @@ import axios from 'axios'
|
||||||
import useLogger from '~/composables/useLogger'
|
import useLogger from '~/composables/useLogger'
|
||||||
import useFormData from '~/composables/useFormData'
|
import useFormData from '~/composables/useFormData'
|
||||||
|
|
||||||
|
import { clear as clearIDB } from 'idb-keyval'
|
||||||
|
import { useQueue } from '~/composables/audio/queue'
|
||||||
|
|
||||||
export type Permission = 'settings' | 'library' | 'moderation'
|
export type Permission = 'settings' | 'library' | 'moderation'
|
||||||
export interface State {
|
export interface State {
|
||||||
authenticated: boolean
|
authenticated: boolean
|
||||||
|
@ -167,6 +170,7 @@ const store: Module<State, RootState> = {
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log('Error while logging out, probably logged in via oauth')
|
console.log('Error while logging out, probably logged in via oauth')
|
||||||
}
|
}
|
||||||
|
|
||||||
const modules = [
|
const modules = [
|
||||||
'auth',
|
'auth',
|
||||||
'favorites',
|
'favorites',
|
||||||
|
@ -175,9 +179,20 @@ const store: Module<State, RootState> = {
|
||||||
'queue',
|
'queue',
|
||||||
'radios'
|
'radios'
|
||||||
]
|
]
|
||||||
modules.forEach(m => {
|
|
||||||
commit(`${m}/reset`, null, { root: true })
|
for (const module of modules) {
|
||||||
})
|
commit(`${module}/reset`, null, { root: true })
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clear session storage
|
||||||
|
sessionStorage.clear()
|
||||||
|
|
||||||
|
// Clear track queue
|
||||||
|
await useQueue().clear()
|
||||||
|
|
||||||
|
// Clear all indexedDB data
|
||||||
|
await clearIDB()
|
||||||
|
|
||||||
logger.info('Log out, goodbye!')
|
logger.info('Log out, goodbye!')
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue