feat: redesign photo overview (masonry + lightbox) and fix hoch/quer search

The album search could not distinguish portrait from landscape: the format
filter ran client-side over a single 60-item page and relied on exifInfo that
Immich never returned (no withExif flag), so the orientation guard fell
through and every photo matched every filter. Pagination links also dropped
format/jahr on the next page.

- immich/client: send withExif: true on /search/metadata so
  exifImageWidth/Height are populated for orientation filtering and masonry
  aspect ratios.
- albums/filter (new): filter + paginate across the full fetched set so total,
  page slice and has-more-pages stay consistent with active filters; both the
  album detail and the cross-album search pages use it.
- albums/photo-gallery (new client component): masonry grid with native
  EXIF aspect ratios (object-fit: cover, no more 3:2 letterboxing), hover
  overlay with filename/date + merken/lizenzieren/vergrößern, and a
  full-screen lightbox with keyboard nav (Esc/arrow keys).
- catalog-content: drop the old PhotoContactSheet; keep AlbumContactSheet and
  thread format/jahr through PhotoPagination links.
- Album detail search form restyled to the editorial design system (sharp ink
  borders) instead of the shadcn rounded card.
- Tests: filter.test.ts covers the orientation/year/pagination logic;
  catalog-content.test.tsx updated to the gallery + lightbox structure;
  immich client test expects withExif: true.

Skipped: global search form still uses shadcn styling (visually inconsistent
but functionally fixed); albums > 1000 photos lose tail items (noted with a
ponytail ceiling comment).

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Leon TonhäuserandClaude committed 2026-08-11 13:36:46 +02:00
1 parent b81cd7c3e2
commit a3ec068cac
11 files changed
+949 -267

No files matched your search

+52 -47
View File
@@ -1,9 +1,10 @@
// @vitest-environment jsdom
import { cleanup, render, screen } from "@testing-library/react";
import { cleanup, fireEvent, render, screen } from "@testing-library/react";
import { afterEach, expect, test } from "vitest";
import { AlbumContactSheet, PhotoContactSheet } from "./catalog-content";
import { AlbumContactSheet } from "./catalog-content";
import { PhotoGallery } from "./photo-gallery";
afterEach(cleanup);
@@ -30,42 +31,27 @@ test("renders granted albums as labelled contact-sheet links", () => {
);
});
test("renders a labelled photo search and descriptive contact-sheet metadata", () => {
render(
<PhotoContactSheet
albumName="Heimspiel gegen Nord"
page={{
items: [
{
id: "asset-1",
type: "IMAGE",
originalFileName: "tor-des-sieges.jpg",
originalMimeType: "image/jpeg",
localDateTime: "2026-08-08T18:42:00.000Z",
fileCreatedAt: null,
albums: [{ id: "heimspiel" }],
},
],
total: 1,
nextPage: null,
previousPage: null,
}}
query="Tor"
/>,
);
const photo = {
id: "asset-1",
type: "IMAGE" as const,
originalFileName: "tor-des-sieges.jpg",
originalMimeType: "image/jpeg",
localDateTime: "2026-08-08T18:42:00.000Z",
fileCreatedAt: null,
albums: [{ id: "heimspiel" }],
};
expect(screen.getByRole("search", { name: /fotos in heimspiel gegen nord durchsuchen/i })).not.toBeNull();
expect((screen.getByRole("searchbox", { name: /suchbegriff/i }) as HTMLInputElement).value).toBe("Tor");
test("renders the gallery list labelled by album name", () => {
render(<PhotoGallery albumName="Heimspiel gegen Nord" items={[photo]} />);
expect(screen.getByRole("list", { name: /fotos aus heimspiel gegen nord/i })).not.toBeNull();
expect(screen.getByAltText("tor-des-sieges.jpg").getAttribute("src")).toBe(
"/api/assets/asset-1/thumbnail",
);
expect(screen.getByText("tor-des-sieges.jpg")).not.toBeNull();
expect(screen.getByText(/1 foto gefunden/i)).not.toBeNull();
});
test("renders the server-scoped download choices for a catalog photo", () => {
render(
<PhotoContactSheet
<PhotoGallery
albumId="33333333-3333-4333-8333-333333333333"
albumName="Heimspiel gegen Nord"
downloadOptions={{
@@ -80,25 +66,44 @@ test("renders the server-scoped download choices for a catalog photo", () => {
],
},
}}
page={{
items: [
{
id: "22222222-2222-4222-8222-222222222222",
type: "IMAGE",
originalFileName: "tor.jpg",
originalMimeType: "image/jpeg",
localDateTime: null,
fileCreatedAt: null,
albums: [{ id: "33333333-3333-4333-8333-333333333333" }],
},
],
total: 1,
nextPage: null,
previousPage: null,
}}
query=""
items={[
{
id: "22222222-2222-4222-8222-222222222222",
type: "IMAGE",
originalFileName: "tor.jpg",
originalMimeType: "image/jpeg",
localDateTime: null,
fileCreatedAt: null,
albums: [{ id: "33333333-3333-4333-8333-333333333333" }],
},
]}
/>,
);
expect(screen.getByRole("button", { name: /original laden/i })).not.toBeNull();
});
test("opens a full-screen lightbox when a photo tile is clicked", () => {
render(
<PhotoGallery
albumName="Heimspiel gegen Nord"
items={[
{ ...photo, id: "a", originalFileName: "first.jpg" },
{ ...photo, id: "b", originalFileName: "second.jpg" },
]}
/>,
);
// No lightbox before clicking.
expect(screen.queryByRole("dialog")).toBeNull();
fireEvent.click(screen.getByRole("button", { name: /first\.jpg vergrößern/i }));
const dialog = screen.getByRole("dialog");
expect(dialog.getAttribute("aria-modal")).toBe("true");
// Lightbox image + tile image both carry the alt, so the dialog contains one.
expect(dialog.querySelector(".lightbox-image")?.getAttribute("alt")).toBe("first.jpg");
expect(screen.getByRole("button", { name: /nächstes bild/i })).not.toBeNull();
// No previous on the first photo.
expect(screen.queryByRole("button", { name: /vorheriges bild/i })).toBeNull();
});
+33 -89
View File
@@ -2,9 +2,6 @@
import Link from "next/link";
import { UsageDialog } from "@/components/download/usage-dialog";
import { LightboxToggleButton } from "@/app/redaktion/leuchtkasten/LightboxToggleButton";
import type { EditorialDownloadOptions } from "@/modules/downloads/stream";
import type { ImmichSearchPage } from "@/modules/immich/types";
import type { VisibleAlbum } from "./catalog";
@@ -41,89 +38,24 @@ export function AlbumContactSheet({ albums }: Readonly<{ albums: VisibleAlbum[]
);
}
export function PhotoContactSheet({
albumId,
albumName,
currentPage = 1,
downloadOptions,
page,
query,
showAlbumName = false,
lightboxAssetIds,
}: Readonly<{
albumId?: string;
albumName: string;
currentPage?: number;
downloadOptions?: EditorialDownloadOptions;
page: ImmichSearchPage;
query: string;
showAlbumName?: boolean;
lightboxAssetIds?: Set<string>;
}>) {
return (
<>
<p aria-live="polite" className="result-summary" role="status">
{formatCount(page.total, "Foto")} gefunden
</p>
{page.items.length === 0 ? (
<p className="catalog-empty">Keine Fotos passen zu dieser Suche. Ändern Sie den Suchbegriff oder wählen Sie ein anderes Album.</p>
) : (
<ul className="photo-contact-sheet" aria-label={`Fotos aus ${albumName}`}>
{page.items.map((asset) => (
<li key={asset.id}>
<figure className="photo-contact-frame relative group">
<img
alt={asset.originalFileName}
className="contact-sheet-image"
height="600"
src={thumbnailUrl(asset.id)}
width="900"
/>
{lightboxAssetIds && (
<div className="absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity">
<LightboxToggleButton assetId={asset.id} initialInLightbox={lightboxAssetIds.has(asset.id)} />
</div>
)}
<figcaption className="contact-strip">
<span className="contact-strip-name">{asset.originalFileName}</span>
{showAlbumName && (asset as any).albums && (asset as any).albums.length > 0 && (
<span className="contact-strip-album">{(asset as any).albums[0].albumName}</span>
)}
<span>{formatDate(asset.localDateTime ?? asset.fileCreatedAt)}</span>
</figcaption>
{(albumId ?? asset.albums?.[0]?.id) && downloadOptions ? (
<UsageDialog
albumId={albumId ?? (asset.albums?.[0]?.id as string)}
assetId={asset.id}
filename={asset.originalFileName}
newUsagePriceCents={downloadOptions.priceCents}
priorUsages={downloadOptions.priorUsagesByAsset[asset.id] ?? []}
/>
) : null}
</figure>
</li>
))}
</ul>
)}
{albumId ? (
<PhotoPagination albumId={albumId} currentPage={currentPage} page={page} query={query} />
) : null}
</>
);
}
// Immich v3 returns `nextPage` as an opaque cursor (or null), not the next
// page number, so links are derived from the current page number instead:
// previous = currentPage - 1, next = currentPage + 1. `nextPage !== null`
// is the authoritative has-more-pages signal.
function PhotoPagination({
// Server-rendered pagination. Links thread every active filter (suche,
// format, jahr) so flipping pages does not silently drop them — that was the
// old bug: pageHref only carried `suche`, so "Nächste Seite" reset format/jahr.
export function PhotoPagination({
albumId,
currentPage,
page,
query,
}: Readonly<{ albumId: string; currentPage: number; page: ImmichSearchPage; query: string }>) {
format,
jahr,
}: Readonly<{
albumId: string;
currentPage: number;
page: ImmichSearchPage;
query: string;
format?: string;
jahr?: string;
}>) {
const hasPrev = currentPage > 1;
const hasNext = page.nextPage !== null;
if (!hasPrev && !hasNext) {
@@ -132,29 +64,41 @@ function PhotoPagination({
return (
<nav aria-label="Suchergebnisseiten" className="photo-pagination">
{hasPrev ? <Link href={pageHref(albumId, currentPage - 1, query)}>Vorherige Seite</Link> : null}
{hasNext ? <Link href={pageHref(albumId, currentPage + 1, query)}>Nächste Seite</Link> : null}
{hasPrev ? <Link href={pageHref(albumId, currentPage - 1, query, format, jahr)}>Vorherige Seite</Link> : null}
{hasNext ? <Link href={pageHref(albumId, currentPage + 1, query, format, jahr)}>Nächste Seite</Link> : null}
</nav>
);
}
function thumbnailUrl(assetId: string): string {
export function thumbnailUrl(assetId: string): string {
return `/api/assets/${encodeURIComponent(assetId)}/thumbnail`;
}
function pageHref(albumId: string, page: number, query: string): string {
export function pageHref(
albumId: string,
page: number,
query: string,
format?: string,
jahr?: string,
): string {
const parameters = new URLSearchParams({ page: String(page) });
if (query) {
parameters.set("suche", query);
}
if (format) {
parameters.set("format", format);
}
if (jahr) {
parameters.set("jahr", jahr);
}
return `/redaktion/alben/${encodeURIComponent(albumId)}?${parameters.toString()}`;
}
function formatCount(count: number, noun: string): string {
export function formatCount(count: number, noun: string): string {
return `${count} ${noun}${count === 1 ? "" : "s"}`;
}
function formatDate(value: string | null): string {
export function formatDate(value: string | null): string {
if (!value) {
return "Ohne Zeitangabe";
}
@@ -164,4 +108,4 @@ function formatDate(value: string | null): string {
return "Ohne Zeitangabe";
}
return new Intl.DateTimeFormat("de-DE", { dateStyle: "medium" }).format(date);
}
}
+2 -1
View File
@@ -14,6 +14,7 @@ export type SearchVisiblePhotosInput = {
requestedAlbumId?: string;
description?: unknown;
page?: unknown;
size?: number;
};
export type AlbumCatalogDependencies = {
@@ -59,7 +60,7 @@ export function createAlbumCatalog({ grants, immich }: AlbumCatalogDependencies)
...(description === undefined ? {} : { description }),
type: "IMAGE",
page: normalizePage(input.page),
size: PHOTO_PAGE_SIZE,
size: input.size ?? PHOTO_PAGE_SIZE,
});
} catch {
throw new AlbumCatalogError("IMMICH_UNAVAILABLE");
+88
View File
@@ -0,0 +1,88 @@
import { expect, test } from "vitest";
import { filterPhotos, matchesOrientation, matchesYear, paginatePhotos } from "./filter";
import type { ImmichAsset } from "@/modules/immich/types";
function photo(overrides: Partial<ImmichAsset> & { id: string }): ImmichAsset {
return {
id: overrides.id,
type: "IMAGE",
originalFileName: overrides.originalFileName ?? `${overrides.id}.jpg`,
originalMimeType: "image/jpeg",
localDateTime: overrides.localDateTime ?? null,
fileCreatedAt: overrides.fileCreatedAt ?? null,
albums: overrides.albums ?? [],
exifInfo: overrides.exifInfo ?? null,
};
}
test("matchesOrientation distinguishes landscape from portrait via EXIF dimensions", () => {
const landscape = photo({ id: "l", exifInfo: { exifImageWidth: 1600, exifImageHeight: 900 } });
const portrait = photo({ id: "p", exifInfo: { exifImageWidth: 900, exifImageHeight: 1600 } });
const square = photo({ id: "s", exifInfo: { exifImageWidth: 1000, exifImageHeight: 1000 } });
expect(matchesOrientation(landscape, "quer")).toBe(true);
expect(matchesOrientation(landscape, "hoch")).toBe(false);
expect(matchesOrientation(portrait, "quer")).toBe(false);
expect(matchesOrientation(portrait, "hoch")).toBe(true);
// width >= height counts as landscape, so square is "quer".
expect(matchesOrientation(square, "quer")).toBe(true);
});
test("matchesOrientation excludes assets with unknown dimensions instead of matching either format", () => {
const unknown = photo({ id: "u", exifInfo: null });
expect(matchesOrientation(unknown, "quer")).toBe(false);
expect(matchesOrientation(unknown, "hoch")).toBe(false);
});
test("matchesYear compares against localDateTime then fileCreatedAt", () => {
expect(matchesYear(photo({ id: "a", localDateTime: "2026-05-01T10:00:00.000Z" }), "2026")).toBe(true);
expect(matchesYear(photo({ id: "b", localDateTime: "2025-12-31T23:00:00.000Z" }), "2026")).toBe(false);
expect(matchesYear(photo({ id: "c", localDateTime: null, fileCreatedAt: "2026-01-01T00:00:00.000Z" }), "2026")).toBe(true);
expect(matchesYear(photo({ id: "d", localDateTime: null, fileCreatedAt: null }), "2026")).toBe(false);
});
test("filterPhotos applies format and jahr together across the full set", () => {
const items = [
photo({ id: "l26", originalFileName: "land26", localDateTime: "2026-03-01", exifInfo: { exifImageWidth: 2, exifImageHeight: 1 } }),
photo({ id: "p26", originalFileName: "port26", localDateTime: "2026-03-01", exifInfo: { exifImageWidth: 1, exifImageHeight: 2 } }),
photo({ id: "l25", originalFileName: "land25", localDateTime: "2025-03-01", exifInfo: { exifImageWidth: 2, exifImageHeight: 1 } }),
];
expect(filterPhotos(items, { format: "quer" }).map((p) => p.id)).toEqual(["l26", "l25"]);
expect(filterPhotos(items, { format: "hoch" }).map((p) => p.id)).toEqual(["p26"]);
expect(filterPhotos(items, { format: "quer", jahr: "2026" }).map((p) => p.id)).toEqual(["l26"]);
expect(filterPhotos(items, {})).toEqual(items);
});
test("paginatePhotos slices the filtered set and signals more pages", () => {
const items = Array.from({ length: 130 }, (_, i) => photo({ id: `p${i}` }));
const { result: page1, currentPage: c1 } = paginatePhotos(items, "1", 60);
expect(c1).toBe(1);
expect(page1.total).toBe(130);
expect(page1.items).toHaveLength(60);
expect(page1.nextPage).toBe(2);
expect(page1.previousPage).toBeNull();
const { result: page3, currentPage: c3 } = paginatePhotos(items, "3", 60);
expect(c3).toBe(3);
expect(page3.items).toHaveLength(10);
expect(page3.nextPage).toBeNull();
expect(page3.previousPage).toBe(2);
});
test("paginatePhotos clamps an out-of-range page to the last page", () => {
const items = Array.from({ length: 70 }, (_, i) => photo({ id: `p${i}` }));
const { result, currentPage } = paginatePhotos(items, "99", 60);
expect(currentPage).toBe(2);
expect(result.items).toHaveLength(10);
expect(result.nextPage).toBeNull();
});
test("paginatePhotos handles an empty set without dividing by zero", () => {
const { result, currentPage } = paginatePhotos([], "1", 60);
expect(currentPage).toBe(1);
expect(result.items).toEqual([]);
expect(result.nextPage).toBeNull();
expect(result.previousPage).toBeNull();
});
+71
View File
@@ -0,0 +1,71 @@
import type { ImmichAsset } from "@/modules/immich/types";
import { normalizePage } from "./catalog";
/**
* Filter + paginate a photo set in-app, used by the album detail and the
* cross-album search pages. Immich's `/search/metadata` paginates server-side
* and does not expose an orientation predicate, so hoch/quer and jahr filters
* are applied across the full fetched set before slicing the requested page.
* This keeps `total`, the page slice, and the has-more-pages signal consistent
* with the active filters — the old client-side filter on a single 60-item
* page silently dropped matching photos and reported the unfiltered total.
*/
export function matchesOrientation(asset: ImmichAsset, format: string): boolean {
const width = asset.exifInfo?.exifImageWidth ?? 0;
const height = asset.exifInfo?.exifImageHeight ?? 0;
// Unknown dimensions can't satisfy a format filter — exclude rather than
// show a portrait under "Querformat" (the original bug). `withExif: true`
// keeps this rare in practice.
if (width <= 0 || height <= 0) return false;
const isLandscape = width >= height;
return format === "quer" ? isLandscape : !isLandscape;
}
export function matchesYear(asset: ImmichAsset, jahr: string): boolean {
const value = asset.localDateTime ?? asset.fileCreatedAt;
return value !== null && value.startsWith(jahr);
}
export function filterPhotos(
items: ImmichAsset[],
filters: { format?: string; jahr?: string },
): ImmichAsset[] {
let filtered = items;
if (filters.format) {
filtered = filtered.filter((asset) => matchesOrientation(asset, filters.format!));
}
if (filters.jahr) {
filtered = filtered.filter((asset) => matchesYear(asset, filters.jahr!));
}
return filtered;
}
export type InAppPage = {
items: ImmichAsset[];
total: number;
nextPage: number | null;
previousPage: number | null;
};
export function paginatePhotos(
items: ImmichAsset[],
page: unknown,
pageSize: number,
): { result: InAppPage; currentPage: number } {
const total = items.length;
const totalPages = Math.max(1, Math.ceil(total / pageSize));
const currentPage = Math.min(normalizePage(page), totalPages);
const start = (currentPage - 1) * pageSize;
const pageItems = items.slice(start, start + pageSize);
return {
currentPage,
result: {
items: pageItems,
total,
nextPage: currentPage < totalPages ? currentPage + 1 : null,
previousPage: currentPage > 1 ? currentPage - 1 : null,
},
};
}
+204
View File
@@ -0,0 +1,204 @@
"use client";
/* eslint-disable @next/next/no-img-element */
import { useEffect, useState, type CSSProperties } from "react";
import { UsageDialog } from "@/components/download/usage-dialog";
import { LightboxToggleButton } from "@/app/redaktion/leuchtkasten/LightboxToggleButton";
import type { EditorialDownloadOptions } from "@/modules/downloads/stream";
import type { ImmichAsset } from "@/modules/immich/types";
import { formatDate, thumbnailUrl } from "./catalog-content";
type PhotoGalleryProps = Readonly<{
albumId?: string;
albumName: string;
items: ImmichAsset[];
downloadOptions?: EditorialDownloadOptions;
/** Pre-selected asset ids, passed as a plain array (Sets don't cross the RSC boundary). */
lightboxAssetIds?: string[];
showAlbumName?: boolean;
}>;
export function PhotoGallery({
albumId,
albumName,
items,
downloadOptions,
lightboxAssetIds,
showAlbumName,
}: PhotoGalleryProps) {
const [openIndex, setOpenIndex] = useState<number | null>(null);
const inLightbox = new Set(lightboxAssetIds);
// Keyboard nav + scroll lock while the lightbox is open. ponytail: a single
// window listener is enough; the lightbox is the only overlay in this view.
useEffect(() => {
if (openIndex === null) return;
function onKey(event: KeyboardEvent) {
if (event.key === "Escape") {
setOpenIndex(null);
} else if (event.key === "ArrowRight") {
setOpenIndex((i) => (i === null ? i : Math.min(i + 1, items.length - 1)));
} else if (event.key === "ArrowLeft") {
setOpenIndex((i) => (i === null ? i : Math.max(i - 1, 0)));
}
}
window.addEventListener("keydown", onKey);
const previousOverflow = document.body.style.overflow;
document.body.style.overflow = "hidden";
return () => {
window.removeEventListener("keydown", onKey);
document.body.style.overflow = previousOverflow;
};
}, [openIndex, items.length]);
if (items.length === 0) {
return (
<p className="catalog-empty">
Keine Fotos passen zu dieser Suche. Ändern Sie den Suchbegriff oder wählen Sie ein anderes Album.
</p>
);
}
return (
<>
<ul className="photo-gallery" aria-label={`Fotos aus ${albumName}`}>
{items.map((asset, index) => {
const activeAlbumId = albumId ?? (asset.albums?.[0]?.id as string | undefined);
return (
<li key={asset.id} className="photo-tile">
<figure className="photo-tile-frame">
<button
className="photo-tile-trigger"
type="button"
onClick={() => setOpenIndex(index)}
aria-label={`${asset.originalFileName} vergrößern`}
>
<img
alt={asset.originalFileName}
className="photo-tile-image"
loading="lazy"
src={thumbnailUrl(asset.id)}
style={aspectStyle(asset)}
/>
</button>
<div className="photo-tile-overlay">
<figcaption className="photo-tile-caption">
<span className="photo-tile-name">{asset.originalFileName}</span>
{showAlbumName ? renderAlbumName(asset) : null}
<span className="photo-tile-date">{formatDate(asset.localDateTime ?? asset.fileCreatedAt)}</span>
</figcaption>
<div className="photo-tile-actions">
<LightboxToggleButton assetId={asset.id} initialInLightbox={inLightbox.has(asset.id)} />
{activeAlbumId && downloadOptions ? (
<UsageDialog
albumId={activeAlbumId}
assetId={asset.id}
filename={asset.originalFileName}
newUsagePriceCents={downloadOptions.priceCents}
priorUsages={downloadOptions.priorUsagesByAsset[asset.id] ?? []}
/>
) : null}
</div>
</div>
</figure>
</li>
);
})}
</ul>
{openIndex !== null ? (
<PhotoLightbox
asset={items[openIndex]}
albumId={albumId}
downloadOptions={downloadOptions}
inLightbox={inLightbox.has(items[openIndex].id)}
hasPrev={openIndex > 0}
hasNext={openIndex < items.length - 1}
onClose={() => setOpenIndex(null)}
onPrev={() => setOpenIndex((i) => Math.max((i ?? 0) - 1, 0))}
onNext={() => setOpenIndex((i) => Math.min((i ?? 0) + 1, items.length - 1))}
/>
) : null}
</>
);
}
type PhotoLightboxProps = Readonly<{
asset: ImmichAsset;
albumId?: string;
downloadOptions?: EditorialDownloadOptions;
inLightbox: boolean;
hasPrev: boolean;
hasNext: boolean;
onClose: () => void;
onPrev: () => void;
onNext: () => void;
}>;
function PhotoLightbox({
asset,
albumId,
downloadOptions,
inLightbox,
hasPrev,
hasNext,
onClose,
onPrev,
onNext,
}: PhotoLightboxProps) {
const activeAlbumId = albumId ?? (asset.albums?.[0]?.id as string | undefined);
return (
<div className="photo-lightbox" role="dialog" aria-modal="true" aria-label={asset.originalFileName}>
<button className="lightbox-close" type="button" onClick={onClose} aria-label="Schließen">
✕
</button>
{hasPrev ? (
<button className="lightbox-nav lightbox-prev" type="button" onClick={onPrev} aria-label="Vorheriges Bild">
‹
</button>
) : null}
{hasNext ? (
<button className="lightbox-nav lightbox-next" type="button" onClick={onNext} aria-label="Nächstes Bild">
›
</button>
) : null}
<figure className="lightbox-figure">
<img alt={asset.originalFileName} className="lightbox-image" src={thumbnailUrl(asset.id)} />
<figcaption className="lightbox-caption">
<span className="photo-tile-name">{asset.originalFileName}</span>
<span className="photo-tile-date">{formatDate(asset.localDateTime ?? asset.fileCreatedAt)}</span>
</figcaption>
</figure>
<div className="lightbox-actions">
<LightboxToggleButton assetId={asset.id} initialInLightbox={inLightbox} />
{activeAlbumId && downloadOptions ? (
<UsageDialog
albumId={activeAlbumId}
assetId={asset.id}
filename={asset.originalFileName}
newUsagePriceCents={downloadOptions.priceCents}
priorUsages={downloadOptions.priorUsagesByAsset[asset.id] ?? []}
/>
) : null}
</div>
</div>
);
}
function aspectStyle(asset: ImmichAsset): CSSProperties {
const width = asset.exifInfo?.exifImageWidth ?? 0;
const height = asset.exifInfo?.exifImageHeight ?? 0;
return width > 0 && height > 0 ? { aspectRatio: `${width} / ${height}` } : {};
}
// `ImmichAsset.albums` is typed as `{ id }[]` but the `/search/metadata`
// response (parsed with `.passthrough()`) also carries `albumName`, which the
// cross-album search view surfaces. Read it via an unknown cast so the typed
// contract stays honest while still rendering the field when Immich sends it.
function renderAlbumName(asset: ImmichAsset) {
const first = (asset as unknown as { albums?: Array<{ albumName?: string }> }).albums?.[0];
return first?.albumName ? <span className="photo-tile-album">{first.albumName}</span> : null;
}
+1
View File
@@ -98,6 +98,7 @@ test("forces IMAGE and authorized album IDs in metadata search", async () => {
type: "IMAGE",
page: 1,
size: 60,
withExif: true,
});
return HttpResponse.json(immichMetadataSearchResponse);
}),
+5
View File
@@ -369,6 +369,11 @@ export function createImmichClient({
type: "IMAGE",
page: input.page,
size: input.size,
// Required so exifImageWidth/exifImageHeight are populated — the
// album page filters by orientation (hoch/quer) and lays out the
// masonry grid from each asset's native aspect ratio. Without it
// Immich returns exifInfo as null and both break.
withExif: true,
}),
},
metadataSearchSchema.transform(({ assets }) => ({