fix: fetch real book counts in Stripstream getSeriesById to fix greyed covers
All checks were successful
Build, Push & Deploy / deploy (push) Successful in 4m18s
All checks were successful
Build, Push & Deploy / deploy (push) Successful in 4m18s
bookCount and booksReadCount were hardcoded to 0, causing all series covers to appear completed (opacity-50). Now queries the series endpoint to get actual counts. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -86,6 +86,11 @@ export class StripstreamProvider implements IMediaProvider {
|
||||
revalidate: CACHE_TTL_MED,
|
||||
});
|
||||
if (!book.series) return null;
|
||||
|
||||
// Try to find series in library to get real book counts
|
||||
const seriesInfo = await this.findSeriesByName(book.series, book.library_id);
|
||||
if (seriesInfo) return seriesInfo;
|
||||
|
||||
return {
|
||||
id: seriesId,
|
||||
name: book.series,
|
||||
@@ -108,6 +113,10 @@ export class StripstreamProvider implements IMediaProvider {
|
||||
);
|
||||
if (!page.items.length) return null;
|
||||
const firstBook = page.items[0];
|
||||
|
||||
const seriesInfo = await this.findSeriesByName(seriesId, firstBook.library_id);
|
||||
if (seriesInfo) return seriesInfo;
|
||||
|
||||
return {
|
||||
id: firstBook.id,
|
||||
name: seriesId,
|
||||
@@ -126,6 +135,21 @@ export class StripstreamProvider implements IMediaProvider {
|
||||
}
|
||||
}
|
||||
|
||||
private async findSeriesByName(seriesName: string, libraryId: string): Promise<NormalizedSeries | null> {
|
||||
try {
|
||||
const seriesPage = await this.client.fetch<StripstreamSeriesPage>(
|
||||
`libraries/${libraryId}/series`,
|
||||
{ q: seriesName, limit: "10" },
|
||||
{ revalidate: CACHE_TTL_MED }
|
||||
);
|
||||
const match = seriesPage.items.find((s) => s.name === seriesName);
|
||||
if (match) return StripstreamAdapter.toNormalizedSeries(match);
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
async getBooks(filter: BookListFilter): Promise<NormalizedBooksPage> {
|
||||
const limit = filter.limit ?? 24;
|
||||
const params: Record<string, string | undefined> = { limit: String(limit) };
|
||||
|
||||
Reference in New Issue
Block a user