Fixed categories not updating
This commit is contained in:
@@ -6,9 +6,7 @@ const { categories } = defineProps<{
|
||||
categories: Category[]
|
||||
}>()
|
||||
|
||||
const sortedCategories = computed(() => {
|
||||
return categories.toSorted((a, b) => a.name.localeCompare(b.name))
|
||||
})
|
||||
const sortedCategories = computed(() => categories.toSorted((a, b) => a.name.localeCompare(b.name)))
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
@@ -41,12 +41,11 @@ const {
|
||||
const isLoading = computed(() => calendarStatus.value === "pending" || categoriesStatus.value === "pending")
|
||||
|
||||
const { setActiveCalendar } = useCalendar()
|
||||
watch(isLoading, (n) => {
|
||||
if (!n && calendar.value?.data && categories.value?.data) {
|
||||
watch([calendar, categories], () => {
|
||||
if (calendar.value?.data && categories.value?.data) {
|
||||
setActiveCalendar(calendar.value?.data, categories.value.data)
|
||||
}
|
||||
}, { immediate: true }
|
||||
)
|
||||
}, { immediate: true })
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
@@ -918,12 +918,11 @@ export const useCalendar = defineStore("calendar", () => {
|
||||
*/
|
||||
function updateAllEventsCategories(categories: Category[]) {
|
||||
baseEvents.value.forEach((event) => {
|
||||
if (event.category?.id) {
|
||||
const category = categories.find((c) => c.id === event.category?.id)
|
||||
if (category) {
|
||||
|
||||
if (category && event.category?.id) {
|
||||
event.category = category
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user