Skip to content

Commit

Permalink
🔧 Fix comment+reply duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
Lezek123 committed Dec 22, 2024
1 parent c6592b5 commit 41d00c1
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/atlas/src/hooks/useOptimisticActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -288,7 +293,7 @@ export const useOptimisticActions = () => {
tip,
}: Omit<AddCommentActionParams, 'parentCommentId'> & { parentCommentId?: string }) => {
const commentId = Date.now()
const recordId = `${commentId}-${videoId}-${UNCONFIRMED_COMMENT}`
const recordId = `${commentId}/${videoId}/${parentCommentId || 'none'}/${UNCONFIRMED_COMMENT}`
client.cache.writeFragment<CommentFieldsFragment>({
id: `Comment:${recordId}`,
fragment: CommentFieldsFragmentDoc,
Expand Down

0 comments on commit 41d00c1

Please sign in to comment.