chore(all): update multifeed views

This commit is contained in:
plebeius.eth
2023-10-21 13:45:42 +02:00
parent 9f5f2d1663
commit 2a95903466
3 changed files with 12 additions and 23 deletions
-7
View File
@@ -312,18 +312,11 @@ const Board = () => {
const maxRepliesPerThread = 5;
return selectedFeed.reduce((acc, thread) => {
// Get replies that are already in the thread
const existingReplies = flattenedRepliesByThread[thread.cid] || [];
// Get replies that belong to this thread but are not yet in the thread
const newReplies = accountComments.filter(
(accountReply) => accountReply.parentCid === thread.cid || existingReplies.some((reply) => reply.cid === accountReply.parentCid),
);
// Combine and sort all the replies
const combinedReplies = [...existingReplies, ...newReplies].sort((a, b) => a.timestamp - b.timestamp);
// Limit the number of displayed replies and count the omitted ones
acc[thread.cid] = {
displayedReplies: combinedReplies.slice(0, maxRepliesPerThread),
omittedCount: Math.max(combinedReplies.length - maxRepliesPerThread, 0),