Fixed hydration errors

Moved some code to client only (it makes sense given the localstorage stuff)
This commit is contained in:
Alexis
2024-05-13 16:06:57 +02:00
parent b49b570fe2
commit df14fad98a
10 changed files with 82 additions and 39 deletions

View File

@@ -10,7 +10,10 @@ import DecadeLayout from './state/decennially/Layout.vue'
import YearLayout from './state/yearly/Layout.vue'
const { currentConfig } = useCalendar()
const { eventsLoaded, eventsAreLoading } = storeToRefs(useCalendarEvents())
const { selectedDate, jumpToDate } = useCalendar()
const { fetchEvents } = useCalendarEvents()
fetchEvents()
const currentViewComponent: ComputedRef<Component> = computed<Component>(() => {
switch (currentConfig.viewType) {
@@ -28,19 +31,18 @@ const currentViewComponent: ComputedRef<Component> = computed<Component>(() => {
return CenturyLayout
}
})
onMounted(() => {
jumpToDate(selectedDate)
})
</script>
<template>
<div class="h-full grid grid-rows-[auto,1fr]">
<CalendarMenu />
<template v-if="eventsAreLoading">
<div>
Loading
</div>
</template>
<template v-else-if="eventsLoaded">
<component :is="currentViewComponent" v-if="eventsLoaded" />
</template>
<KeepAlive>
<component :is="currentViewComponent" />
</KeepAlive>
</div>
</template>