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