feat: map favorites to batch records

This commit is contained in:
wxs
2026-07-17 12:08:45 +08:00
parent ac8e86ab7b
commit 27a4fbb1aa
2 changed files with 93 additions and 0 deletions
+17
View File
@@ -0,0 +1,17 @@
import type { FavoriteCreator } from "./favorites-store";
import type { MarketRecord } from "./types";
export function toFavoriteMarketRecords(creators: FavoriteCreator[]): MarketRecord[] {
const byAuthorId = new Map<string, FavoriteCreator>();
creators.forEach((creator) => {
if (creator.authorId && !byAuthorId.has(creator.authorId)) {
byAuthorId.set(creator.authorId, creator);
}
});
return Array.from(byAuthorId.values()).map((creator) => ({
authorId: creator.authorId,
authorName: creator.authorName,
...(creator.coreUserId ? { coreUserId: creator.coreUserId } : {}),
status: "idle" as const
}));
}