mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix(accounts): adapt 5chan to compact account history hooks (#1118)
* chore(cursor): use composer-2 for subagents * fix(accounts): adapt 5chan to compact account history hooks * fix(accounts): address 5chan account-history review findings
This commit is contained in:
@@ -1,8 +1,16 @@
|
||||
import { useMemo } from 'react';
|
||||
import { Comment, useAccountComments } from '@bitsocialnet/bitsocial-react-hooks';
|
||||
|
||||
// Keep the hook on its indexed fast path when there are no reply indices to resolve.
|
||||
const EMPTY_ACCOUNT_COMMENT_LOOKUP = { commentIndices: [-1] };
|
||||
|
||||
const useFreshReplies = (replies: Comment[] = []) => {
|
||||
const { accountComments } = useAccountComments();
|
||||
const replyIndices = useMemo(
|
||||
() => Array.from(new Set(replies.map((reply) => reply?.index).filter((replyIndex): replyIndex is number => typeof replyIndex === 'number'))),
|
||||
[replies],
|
||||
);
|
||||
const accountCommentLookupOptions = useMemo(() => (replyIndices.length > 0 ? { commentIndices: replyIndices } : EMPTY_ACCOUNT_COMMENT_LOOKUP), [replyIndices]);
|
||||
const { accountComments } = useAccountComments(accountCommentLookupOptions);
|
||||
|
||||
return useMemo(() => {
|
||||
if (!replies.length || !accountComments?.length) {
|
||||
|
||||
Reference in New Issue
Block a user