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,