mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
Update use-replies.ts
This commit is contained in:
@@ -6,15 +6,15 @@ const useRepliesAndAccountReplies = (comment: Comment) => {
|
|||||||
// flatten all replies including nested ones from the original comment
|
// flatten all replies including nested ones from the original comment
|
||||||
const flattenedReplies = useMemo(() => flattenCommentsPages(comment.replies), [comment.replies]);
|
const flattenedReplies = useMemo(() => flattenCommentsPages(comment.replies), [comment.replies]);
|
||||||
|
|
||||||
// gemerate a Set of CIDs from flattened replies for quick lookup
|
// generate a Set of CIDs from flattened replies for quick lookup
|
||||||
const replyCids = useMemo(() => new Set(flattenedReplies.map((reply) => reply.cid)), [flattenedReplies]);
|
const replyCids = useMemo(() => new Set(flattenedReplies.map((reply) => reply.cid)), [flattenedReplies]);
|
||||||
|
|
||||||
// filter against all CIDs in flattened replies
|
// filter against the original comment's CID and all CIDs in flattened replies
|
||||||
const filter = useCallback(
|
const filter = useCallback(
|
||||||
(accountComment: Comment) => {
|
(accountComment: Comment) => {
|
||||||
return replyCids.has(accountComment.parentCid);
|
return accountComment.parentCid === comment.cid || replyCids.has(accountComment.parentCid);
|
||||||
},
|
},
|
||||||
[replyCids],
|
[comment.cid, replyCids],
|
||||||
);
|
);
|
||||||
|
|
||||||
const { accountComments } = useAccountComments({ filter });
|
const { accountComments } = useAccountComments({ filter });
|
||||||
|
|||||||
Reference in New Issue
Block a user