From b38658077fda4f00fe5828c64267034f19b0d4d6 Mon Sep 17 00:00:00 2001 From: Philipinho <16838612+Philipinho@users.noreply.github.com> Date: Wed, 1 Apr 2026 15:11:48 +0100 Subject: [PATCH] fix: duplicate comment cache --- apps/client/src/features/comment/queries/comment-query.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/apps/client/src/features/comment/queries/comment-query.ts b/apps/client/src/features/comment/queries/comment-query.ts index 6c86c039..6b7432eb 100644 --- a/apps/client/src/features/comment/queries/comment-query.ts +++ b/apps/client/src/features/comment/queries/comment-query.ts @@ -65,6 +65,11 @@ export function useCreateCommentMutation() { ) as InfiniteData> | undefined; 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; queryClient.setQueryData(RQ_KEY(newComment.pageId), { ...cache,