From 41d00c101bd7b490394eb23deeb610794f018aad Mon Sep 17 00:00:00 2001 From: Lezek123 Date: Sun, 22 Dec 2024 19:35:32 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20Fix=20comment+reply=20duplicatio?= =?UTF-8?q?n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/atlas/src/hooks/useOptimisticActions.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/atlas/src/hooks/useOptimisticActions.ts b/packages/atlas/src/hooks/useOptimisticActions.ts index 000a1f4fb3..2159d42ebf 100644 --- a/packages/atlas/src/hooks/useOptimisticActions.ts +++ b/packages/atlas/src/hooks/useOptimisticActions.ts @@ -249,6 +249,11 @@ export const useOptimisticActions = () => { '__ref' in e.node ? e.node.__ref === unconfirmedId : e.node.id === recordId ) }) + .filter( + (unconfirmedId) => + unconfirmedId.split('/')[1] === videoId && + unconfirmedId.split('/')[2] === (parentCommentId || 'none') + ) .map((unconfirmedId) => ({ __typename: 'CommentEdge', cursor: '0', @@ -288,7 +293,7 @@ export const useOptimisticActions = () => { tip, }: Omit & { parentCommentId?: string }) => { const commentId = Date.now() - const recordId = `${commentId}-${videoId}-${UNCONFIRMED_COMMENT}` + const recordId = `${commentId}/${videoId}/${parentCommentId || 'none'}/${UNCONFIRMED_COMMENT}` client.cache.writeFragment({ id: `Comment:${recordId}`, fragment: CommentFieldsFragmentDoc,