fix: duplicate comment cache

This commit is contained in:
Philipinho
2026-04-01 15:11:48 +01:00
parent d774611db0
commit b38658077f
@@ -65,6 +65,11 @@ export function useCreateCommentMutation() {
) as InfiniteData<IPagination<IComment>> | undefined; ) as InfiniteData<IPagination<IComment>> | undefined;
if (cache && cache.pages.length > 0) { if (cache && cache.pages.length > 0) {
const alreadyExists = cache.pages.some((page) =>
page.items.some((c) => c.id === newComment.id),
);
if (alreadyExists) return;
const lastIdx = cache.pages.length - 1; const lastIdx = cache.pages.length - 1;
queryClient.setQueryData(RQ_KEY(newComment.pageId), { queryClient.setQueryData(RQ_KEY(newComment.pageId), {
...cache, ...cache,