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,7 +1,7 @@
|
||||
import { Suspense } from "react";
|
||||
import { ClientBookPage } from "@/components/reader/ClientBookPage";
|
||||
import { BookSkeleton } from "@/components/skeletons/BookSkeleton";
|
||||
import { BookService } from "@/lib/services/book.service";
|
||||
import { getProvider } from "@/lib/providers/provider.factory";
|
||||
import { ERROR_CODES } from "@/constants/errorCodes";
|
||||
import { AppError } from "@/utils/errors";
|
||||
import { redirect } from "next/navigation";
|
||||
@@ -11,23 +11,30 @@ export default async function BookPage({ params }: { params: Promise<{ bookId: s
|
||||
const { bookId } = await params;
|
||||
|
||||
try {
|
||||
// SSR: Fetch directly on server instead of client-side XHR
|
||||
const data = await BookService.getBook(bookId);
|
||||
const provider = await getProvider();
|
||||
if (!provider) redirect("/settings");
|
||||
|
||||
const book = await provider.getBook(bookId);
|
||||
const pages = Array.from({ length: book.pageCount }, (_, i) => i + 1);
|
||||
|
||||
let nextBook = null;
|
||||
try {
|
||||
nextBook = await BookService.getNextBook(bookId, data.book.seriesId);
|
||||
nextBook = await provider.getNextBook(bookId);
|
||||
} catch (error) {
|
||||
logger.warn({ err: error, bookId }, "Failed to fetch next book, continuing without it");
|
||||
}
|
||||
|
||||
return (
|
||||
<Suspense fallback={<BookSkeleton />}>
|
||||
<ClientBookPage bookId={bookId} initialData={{ ...data, nextBook }} />
|
||||
<ClientBookPage bookId={bookId} initialData={{ book, pages, nextBook }} />
|
||||
</Suspense>
|
||||
);
|
||||
} catch (error) {
|
||||
// If config is missing, redirect to settings
|
||||
if (error instanceof AppError && error.code === ERROR_CODES.KOMGA.MISSING_CONFIG) {
|
||||
if (error instanceof AppError && (
|
||||
error.code === ERROR_CODES.KOMGA.MISSING_CONFIG ||
|
||||
error.code === ERROR_CODES.STRIPSTREAM.MISSING_CONFIG
|
||||
)) {
|
||||
redirect("/settings");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user