Added basic caching for calendar page

This commit is contained in:
Alexis
2024-08-24 18:33:54 +02:00
parent 19a71d356e
commit e3a6ff8790
3 changed files with 16 additions and 18 deletions

View File

@@ -21,8 +21,8 @@ watch(user, (n, _o) => {
const route = useRoute()
const id = route.params.id
const { data: calendarData, pending: calPending } = useLazyFetch('/api/calendars/query', { query: { id, full: true } })
const { data: catData, pending: catPending } = useLazyFetch('/api/calendars/categories/query')
const { data: calendarData, pending: calPending } = useLazyFetch('/api/calendars/query', { key: `calendar-${id}`, query: { id, full: true } })
const { data: catData, pending: catPending } = useLazyFetch('/api/calendars/categories/query', { key: `categories-${id}` })
const cal = computed<Calendar>(() => calendarData?.value?.data as Calendar)
const categories = computed<Category[]>(() => catData?.value?.data as Category[])
@@ -37,20 +37,4 @@ const categories = computed<Category[]>(() => catData?.value?.data as Category[]
</div>
<Calendar v-else-if="cal && categories" :calendar-data="cal" :categories />
<!-- <span v-if="calendarData && categories">
<Calendar :calendar-data :categories />
</span> -->
<!-- <Suspense>
<Calendar :calendar="calendar?.data" :categories />
<template #fallback>
<div class="h-full w-full grid place-items-center">
<div class="grid gap-2 justify-items-center opacity-50">
<p>Chargement du calendrier</p>
<PhCircleNotch size="50" class="animate-spin"/>
</div>
</div>
</template>
</Suspense> -->
</template>