From 293042a7b15f7bd49bc51db4b2488c368dc9b143 Mon Sep 17 00:00:00 2001 From: tobinio Date: Sun, 7 Jun 2026 14:56:26 +0200 Subject: [PATCH] fix vue reactivity errors --- app/composables/useCategoryUtils.ts | 5 +++-- app/composables/useInitData.ts | 1 - app/composables/useTagUtils.ts | 5 +++-- app/composables/useTodoUtils.ts | 17 +++++++++-------- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/app/composables/useCategoryUtils.ts b/app/composables/useCategoryUtils.ts index 7d28c72..1fdd1ca 100644 --- a/app/composables/useCategoryUtils.ts +++ b/app/composables/useCategoryUtils.ts @@ -1,7 +1,8 @@ import { useCategoriesQuery } from "~/queries/category"; export function getCategoryByUUID(uuid: UUID | undefined) { - const { data: categories } = useQuery(useCategoriesQuery()); + const queryCache = useQueryCache(); + const categories = queryCache.getQueryData(useCategoriesQuery().key); - return (categories.value ?? []).find((label) => label.uuid === uuid); + return (categories ?? []).find((label) => label.uuid === uuid); } diff --git a/app/composables/useInitData.ts b/app/composables/useInitData.ts index 980d79c..487e27a 100644 --- a/app/composables/useInitData.ts +++ b/app/composables/useInitData.ts @@ -11,7 +11,6 @@ export async function useInitdata(id: Ref) { } function initData() { - initSSE(); queryCache.invalidateQueries(); } diff --git a/app/composables/useTagUtils.ts b/app/composables/useTagUtils.ts index 27f87df..11f7ac1 100644 --- a/app/composables/useTagUtils.ts +++ b/app/composables/useTagUtils.ts @@ -1,7 +1,8 @@ import { useTagsQuery } from "~/queries/tag"; export function getTagByUUID(uuid: UUID | undefined) { - const { data: tags } = useQuery(useTagsQuery()); + const queryCache = useQueryCache(); + const tags = queryCache.getQueryData(useTagsQuery().key); - return (tags.value ?? []).find((label) => label.uuid === uuid); + return (tags ?? []).find((label) => label.uuid === uuid); } diff --git a/app/composables/useTodoUtils.ts b/app/composables/useTodoUtils.ts index 885832b..bb54d45 100644 --- a/app/composables/useTodoUtils.ts +++ b/app/composables/useTodoUtils.ts @@ -1,20 +1,21 @@ import { useTodosQuery } from "~/queries/todo"; export function useTodoById(uuid: UUID) { - const { data: todos } = useQuery(useTodosQuery()); - return (todos.value ?? []).find((todo) => todo.uuid === uuid); + const queryCache = useQueryCache(); + const todos = queryCache.getQueryData(useTodosQuery().key); + return (todos ?? []).find((todo) => todo.uuid === uuid); } export function useIsTagUsed(tagUUID: UUID) { - const { data: todos } = useQuery(useTodosQuery()); - return (todos.value ?? []).some((todo) => + const queryCache = useQueryCache(); + const todos = queryCache.getQueryData(useTodosQuery().key); + return (todos ?? []).some((todo) => todo.tags?.some((tag) => tag.uuid === tagUUID), ); } export function useIsCategoryUsed(categoryUUID: UUID) { - const { data: todos } = useQuery(useTodosQuery()); - return (todos.value ?? []).some( - (todo) => todo.category?.uuid === categoryUUID, - ); + const queryCache = useQueryCache(); + const todos = queryCache.getQueryData(useTodosQuery().key); + return (todos ?? []).some((todo) => todo.category?.uuid === categoryUUID); } -- 2.51.2