fix: support Immich v3 search/metadata cursor pagination

Immich v3 (server runs v3.1.0) returns search `nextPage` as an opaque cursor
string instead of a page number. The client schema validated `nextPage` as
`number`, so every album open failed schema validation and surfaced as
"Fotos momentan nicht erreichbar" (the catalog catch swallows the real
IMMICH_INVALID_RESPONSE into IMMICH_UNAVAILABLE).

Accept `string | number` for nextPage/previousPage in the schema and the
ImmichSearchPage type; we only use nextPage as a has-more-pages signal.
Pagination links are now derived from the current page number (currentPage ± 1)
instead of the returned nextPage value, since the v3 cursor can't be used as a
page number. Album page passes the normalized current page through.

Add a client test locking the v3 cursor-string response.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Leon TonhäuserandClaude committed 2026-08-11 02:23:21 +02:00
1 parent 089f5f7035
commit 8dfaf8284e
6 files changed
+64 -13

No files matched your search

+3 -1
View File
@@ -1,7 +1,7 @@
import Link from "next/link";
import { notFound } from "next/navigation";
import { AlbumCatalogError, albumCatalog } from "@/modules/albums/catalog";
import { AlbumCatalogError, albumCatalog, normalizePage } from "@/modules/albums/catalog";
import { PhotoContactSheet } from "@/modules/albums/catalog-content";
import { loadEditorialDownloadOptions } from "@/modules/downloads/stream";
@@ -19,6 +19,7 @@ export default async function AlbumPage({ params, searchParams }: AlbumPageProps
requireEditorial(),
]);
const query = normalizedQuery(singleValue(rawSearchParams.suche));
const currentPage = normalizePage(singleValue(rawSearchParams.page));
const result = await loadAlbumPage({
editorialId: principal.editorialId,
albumId,
@@ -45,6 +46,7 @@ export default async function AlbumPage({ params, searchParams }: AlbumPageProps
<PhotoContactSheet
albumId={result.album.id}
albumName={result.album.albumName}
currentPage={currentPage}
downloadOptions={result.downloadOptions}
page={result.page}
query={query}