mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix(publish): retry failed comments without duplicate replies
This commit is contained in:
@@ -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]);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user