fix: consume enriched account comments directly (#1178)

* fix: consume enriched account comments directly

* fix(account comments): use empty lookup patch
This commit is contained in:
Tommaso Casaburi
2026-06-24 16:23:42 +07:00
committed by GitHub
parent dff0aef8f8
commit f1022fc2d9
22 changed files with 157 additions and 269 deletions
+19 -1
View File
@@ -142,6 +142,24 @@ const getScopedAccountComments = (options?: { commentIndices?: number[]; communi
return scopedComments;
};
const enrichAccountCommentAuthor = (comment: TestComment): TestComment => {
if (comment.author?.address || !comment.accountId || comment.accountId !== testState.account.id || !testState.account.author?.address) {
return comment;
}
const accountAuthor = testState.account.author;
return {
...comment,
author: {
...accountAuthor,
...comment.author,
address: accountAuthor.address,
...(accountAuthor.shortAddress ? { shortAddress: accountAuthor.shortAddress } : {}),
},
};
};
const getScopedFeed = (options?: { filter?: { filter: (comment: TestComment) => boolean }; newerThan?: number; postsPerPage?: number }) => {
let scopedFeed = [...testState.feed];
@@ -165,7 +183,7 @@ vi.mock('@bitsocial/bitsocial-react-hooks', () => ({
useAccount: () => testState.account,
useAccountComments: (options?: { commentIndices?: number[]; communityAddress?: string; newerThan?: number; sortType?: 'new' | 'old' }) => {
testState.accountCommentsCalls.push(options);
return { accountComments: getScopedAccountComments(options) };
return { accountComments: getScopedAccountComments(options).map(enrichAccountCommentAuthor) };
},
useFeed: (options?: {
communities?: unknown[];