feat: add cache policy from settings

This commit is contained in:
axolotle 2024-08-12 23:45:06 +02:00
parent 354a06af6d
commit 311d5fdc27

View file

@ -12,6 +12,7 @@ import type {
UserDetails,
UserItem,
} from '@/types/core/data'
import { useSettings } from './useSettings'
function getNoDataMessage(key: DataKeys) {
return `No data in cache: you should query '${key}' before.`
@ -219,11 +220,11 @@ export function useCache<T extends any = any>(
| [StoreKeys, undefined]
| [StoreKeysParam, string]
const data = useData()
// FIXME get global cache policy setting
// Add noCache arg? not used
const { cache } = useSettings()
return {
content: computed(() => {
if (!cache.value) return undefined
if (!(key in data)) {
throw new Error('Trying to get cache of inexistant data')
}