Skip to content

Commit 8afbbd9

Browse files
authored
Merge pull request #355 from samueldurantes/fix/comments
Check if comment already exists in UI state to avoid duplication
2 parents e12b098 + f918b5c commit 8afbbd9

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

apps/web/src/hooks/useComments.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ export function CommentsProvider(props: Props) {
7979
const onComment = (data: { documentId: string; comment: Comment }) => {
8080
setState((state) => {
8181
const comments = state.get(data.comment.documentId) ?? []
82+
83+
if (comments.some(({ id }) => id === data.comment.id)) {
84+
return state
85+
}
86+
8287
return state.set(data.comment.documentId, [...comments, data.comment])
8388
})
8489
}

0 commit comments

Comments
 (0)