feat: map favorites to batch records
This commit is contained in:
@@ -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
|
||||
}));
|
||||
}
|
||||
Reference in New Issue
Block a user