fix(publish): retry failed comments without duplicate replies

This commit is contained in:
Tommaso Casaburi
2026-04-10 16:02:10 +07:00
parent 02f8d3467e
commit 5f9e603b62
8 changed files with 385 additions and 17 deletions
+21 -1
View File
@@ -39,7 +39,27 @@ const useFreshReplies = (replies: Comment[] = []) => {
return freshReply;
});
return hasFreshReplies ? nextReplies : replies;
if (!hasFreshReplies) {
return replies;
}
const seenReplyIndices = new Set<number>();
let hasDuplicateReplyIndices = false;
const dedupedReplies = nextReplies.filter((reply) => {
if (typeof reply?.index !== 'number') {
return true;
}
if (seenReplyIndices.has(reply.index)) {
hasDuplicateReplyIndices = true;
return false;
}
seenReplyIndices.add(reply.index);
return true;
});
return hasDuplicateReplyIndices ? dedupedReplies : nextReplies;
}, [accountComments, replies]);
};