mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-11-23 04:46:08 -08:00
feat(stats): group library seasons, movies and OVAs into franchise cards (#336)
This commit is contained in:
1 parent
9d2057cc30
commit
71251b8d7b
41 files changed
+2335
-109
No files matched your search
@@ -0,0 +1,26 @@
|
||||
import type { apiClient } from '../lib/api-client';
|
||||
import type { AnimeLibraryGroup, AnimeLibraryItem } from '../types/stats';
|
||||
|
||||
/** Wraps each entry in a one-part card, as the server does for entries without AniList relations. */
|
||||
export function asSingleGroups(items: AnimeLibraryItem[]): AnimeLibraryGroup[] {
|
||||
return items.map((item) => ({
|
||||
groupKey: -item.animeId,
|
||||
title: item.canonicalTitle,
|
||||
mediaKind: item.mediaKind,
|
||||
coverAnimeId: item.animeId,
|
||||
totalSessions: item.totalSessions,
|
||||
totalActiveMs: item.totalActiveMs,
|
||||
totalCards: item.totalCards,
|
||||
totalTokensSeen: item.totalTokensSeen,
|
||||
episodeCount: item.episodeCount,
|
||||
lastWatchedMs: item.lastWatchedMs,
|
||||
parts: [{ ...item, format: null, startDate: null }],
|
||||
}));
|
||||
}
|
||||
|
||||
/** A `getAnimeLibraryGroups` mock serving `load()`'s entries as one-part cards. */
|
||||
export function singleGroupLibrary(
|
||||
load: () => Promise<AnimeLibraryItem[]>,
|
||||
): typeof apiClient.getAnimeLibraryGroups {
|
||||
return async () => asSingleGroups(await load());
|
||||
}
|
||||
Reference in new issue
Block a user