feat: add multi-provider support (Komga + Stripstream Librarian)
Some checks failed
Deploy with Docker Compose / deploy (push) Has been cancelled
Some checks failed
Deploy with Docker Compose / deploy (push) Has been cancelled
- Introduce provider abstraction layer (IMediaProvider, KomgaProvider, StripstreamProvider) - Add Stripstream Librarian as second media provider with full feature parity - Migrate all pages and components from direct Komga services to provider factory - Remove dead service code (BaseApiService, HomeService, LibraryService, SearchService, TestService) - Fix library/series page-based pagination for both providers (Komga 0-indexed, Stripstream 1-indexed) - Fix unread filter and search on library page for both providers - Fix read progress display for Stripstream (reading_status mapping) - Fix series read status (books_read_count) for Stripstream - Add global search with series results for Stripstream (series_hits from Meilisearch) - Fix thumbnail proxy to return 404 gracefully instead of JSON on upstream error - Replace duration-based cache debug detection with x-nextjs-cache header Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { PreferencesService } from "@/lib/services/preferences.service";
|
||||
import { SeriesService } from "@/lib/services/series.service";
|
||||
import { getProvider } from "@/lib/providers/provider.factory";
|
||||
|
||||
import { FavoriteService } from "@/lib/services/favorite.service";
|
||||
import { SeriesClientWrapper } from "./SeriesClientWrapper";
|
||||
import { SeriesContent } from "./SeriesContent";
|
||||
@@ -7,6 +8,7 @@ import { ErrorMessage } from "@/components/ui/ErrorMessage";
|
||||
import { AppError } from "@/utils/errors";
|
||||
import { ERROR_CODES } from "@/constants/errorCodes";
|
||||
import type { UserPreferences } from "@/types/preferences";
|
||||
import { redirect } from "next/navigation";
|
||||
|
||||
interface PageProps {
|
||||
params: Promise<{ seriesId: string }>;
|
||||
@@ -18,28 +20,38 @@ const DEFAULT_PAGE_SIZE = 20;
|
||||
export default async function SeriesPage({ params, searchParams }: PageProps) {
|
||||
const seriesId = (await params).seriesId;
|
||||
const page = (await searchParams).page;
|
||||
const unread = (await searchParams).unread;
|
||||
const size = (await searchParams).size;
|
||||
|
||||
const unread = (await searchParams).unread;
|
||||
const currentPage = page ? parseInt(page) : 1;
|
||||
const preferences: UserPreferences = await PreferencesService.getPreferences();
|
||||
|
||||
// Utiliser le paramètre d'URL s'il existe, sinon utiliser la préférence utilisateur
|
||||
const unreadOnly = unread !== undefined ? unread === "true" : preferences.showOnlyUnread;
|
||||
const effectivePageSize = size ? parseInt(size) : preferences.displayMode?.itemsPerPage || DEFAULT_PAGE_SIZE;
|
||||
const effectivePageSize = size
|
||||
? parseInt(size)
|
||||
: preferences.displayMode?.itemsPerPage || DEFAULT_PAGE_SIZE;
|
||||
|
||||
try {
|
||||
const [books, series, isFavorite] = await Promise.all([
|
||||
SeriesService.getSeriesBooks(seriesId, currentPage - 1, effectivePageSize, unreadOnly),
|
||||
SeriesService.getSeries(seriesId),
|
||||
const provider = await getProvider();
|
||||
if (!provider) redirect("/settings");
|
||||
|
||||
const [booksPage, series, isFavorite] = await Promise.all([
|
||||
provider.getBooks({
|
||||
seriesName: seriesId,
|
||||
cursor: String(currentPage),
|
||||
limit: effectivePageSize,
|
||||
unreadOnly,
|
||||
}),
|
||||
provider.getSeriesById(seriesId),
|
||||
FavoriteService.isFavorite(seriesId),
|
||||
]);
|
||||
|
||||
if (!series) throw new AppError(ERROR_CODES.SERIES.FETCH_ERROR);
|
||||
|
||||
return (
|
||||
<SeriesClientWrapper seriesId={seriesId}>
|
||||
<SeriesContent
|
||||
series={series}
|
||||
books={books}
|
||||
books={booksPage}
|
||||
currentPage={currentPage}
|
||||
preferences={preferences}
|
||||
unreadOnly={unreadOnly}
|
||||
@@ -49,10 +61,16 @@ export default async function SeriesPage({ params, searchParams }: PageProps) {
|
||||
</SeriesClientWrapper>
|
||||
);
|
||||
} catch (error) {
|
||||
const errorCode = error instanceof AppError
|
||||
? error.code
|
||||
: ERROR_CODES.BOOK.PAGES_FETCH_ERROR;
|
||||
|
||||
if (
|
||||
error instanceof AppError &&
|
||||
(error.code === ERROR_CODES.KOMGA.MISSING_CONFIG ||
|
||||
error.code === ERROR_CODES.STRIPSTREAM.MISSING_CONFIG)
|
||||
) {
|
||||
redirect("/settings");
|
||||
}
|
||||
|
||||
const errorCode = error instanceof AppError ? error.code : ERROR_CODES.BOOK.PAGES_FETCH_ERROR;
|
||||
|
||||
return (
|
||||
<main className="container mx-auto px-4 py-8">
|
||||
<ErrorMessage errorCode={errorCode} />
|
||||
|
||||
Reference in New Issue
Block a user