fix: cache with outdated data
This commit is contained in:
@ -5,6 +5,7 @@ import { API_URL } from '../api'
|
||||
import { cookies } from '../cookies'
|
||||
import { Tokens } from '.'
|
||||
import { fetchRefreshToken } from './authenticationFromServerSide'
|
||||
import { clearCache } from '../cache'
|
||||
|
||||
export class Authentication {
|
||||
public tokens: Tokens
|
||||
@ -99,7 +100,7 @@ export class Authentication {
|
||||
|
||||
public signout(): void {
|
||||
cookies.remove('refreshToken')
|
||||
window.localStorage.clear()
|
||||
clearCache()
|
||||
window.location.href = '/authentication/signin'
|
||||
}
|
||||
|
||||
@ -120,6 +121,7 @@ export class Authentication {
|
||||
}
|
||||
|
||||
public signin(): void {
|
||||
clearCache()
|
||||
cookies.set('refreshToken', this.tokens.refreshToken)
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ export type CacheKey =
|
||||
export const getPaginationCache = <T extends PaginationItem>(
|
||||
key: CacheKey
|
||||
): T[] => {
|
||||
const cache = localStorage.getItem(key)
|
||||
const cache = sessionStorage.getItem(key)
|
||||
if (cache != null) {
|
||||
try {
|
||||
const data = JSON.parse(cache)
|
||||
@ -30,5 +30,9 @@ export const savePaginationCache = <T extends PaginationItem>(
|
||||
key: CacheKey,
|
||||
data: T[]
|
||||
): void => {
|
||||
localStorage.setItem(key, JSON.stringify(data))
|
||||
sessionStorage.setItem(key, JSON.stringify(data))
|
||||
}
|
||||
|
||||
export const clearCache = (): void => {
|
||||
sessionStorage.clear()
|
||||
}
|
||||
|
Reference in New Issue
Block a user