feat: redesign album overview to match photo grid + surface download/merkzettel errors

Album overview:
- AlbumContactSheet now uses cover tiles in the photo-gallery aesthetic:
  object-fit: cover, 4/3 tiles, persistent bottom gradient with album name
  + photo count, hover zoom. Drops the old 3:2 contain tiles + monospace
  caption strip.

Diagnostics (download + merkzettel both failed silently for the user):
- UsageDialog now reads the server's { code } from /api/download-intents and
  maps each stable error code (FORBIDDEN, NOT_FOUND, UPSTREAM_UNAVAILABLE,
  ACCOUNTING_UNAVAILABLE, ...) to a specific German message instead of the
  generic "try again". The fallback includes the raw code so unmapped
  failures stay actionable when reported back.
- LightboxToggleButton logs the caught server-action error to the console
  (and notes the dev terminal) instead of reverting the optimistic toggle
  with no signal. Root cause still needs the live error; this makes it
  visible.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Leon TonhäuserandClaude committed 2026-08-11 13:52:15 +02:00
1 parent a3ec068cac
commit a7df6bd60a
4 files changed
+103 -57

No files matched your search

+44 -4
View File
@@ -87,7 +87,11 @@ export function UsageDialog({
headers: { "content-type": "application/json" },
body: JSON.stringify(payload),
});
if (!response.ok) throw new Error("intent failed");
if (!response.ok) {
const code = await readErrorCode(response);
setError(downloadErrorMessage(code, response.status));
return;
}
const intent = (await response.json()) as IntentResponse;
if (!isLocalDownloadUrl(intent.fileUrl, intent.downloadId)) {
throw new Error("invalid download url");
@@ -99,9 +103,9 @@ export function UsageDialog({
dialogRef.current?.close();
idempotencyKeyRef.current = null;
} catch {
setError(
"Der Download konnte nicht vorbereitet werden. Versuchen Sie dieselbe Anfrage erneut.",
);
// Network failure / response not JSON — the server-code cases are
// handled above; this is only a transport-level failure.
setError("Der Download konnte nicht vorbereitet werden (Netzwerkfehler). Versuchen Sie es erneut.");
} finally {
setPending(false);
}
@@ -220,3 +224,39 @@ function formatDate(value: string): string {
function isLocalDownloadUrl(fileUrl: string, downloadId: string): boolean {
return fileUrl === `/api/downloads/${encodeURIComponent(downloadId)}/file`;
}
async function readErrorCode(response: Response): Promise<string | null> {
try {
const data = (await response.json()) as { code?: unknown };
return typeof data.code === "string" ? data.code : null;
} catch {
return null;
}
}
// Map the server's stable error codes (see intent-handler.ts) to specific
// German messages so the editorial sees the real reason instead of a generic
// "try again". The fallback includes the raw code so unmapped failures are
// still actionable when reported back.
function downloadErrorMessage(code: string | null, status: number): string {
switch (code) {
case "FORBIDDEN":
return "Ihr Konto ist nicht freigegeben oder gesperrt.";
case "INVALID_REQUEST":
return "Die Anfrage war unvollständig. Bitte laden Sie die Seite neu und versuchen Sie es erneut.";
case "IDEMPOTENCY_CONFLICT":
return "Dieser Download wurde bereits registriert. Bitte laden Sie die Seite neu.";
case "NOT_FOUND":
return "Das Bild ist nicht im freigegebenen Album enthalten oder wurde daraus entfernt.";
case "UPSTREAM_UNAVAILABLE":
return "Immich ist momentan nicht erreichbar. Bitte versuchen Sie es in wenigen Minuten erneut.";
case "INVALID_ASSET":
return "Dieses Asset ist kein Bild und kann nicht lizenziert werden.";
case "ACCOUNTING_UNAVAILABLE":
return "Für Ihr Konto ist noch kein Preis hinterlegt. Bitte den Admin, einen Preis festzulegen.";
case "CROSS_ORIGIN_REQUEST":
return "Die Anfrage wurde aus einer unzulässigen Herkunft gestellt.";
default:
return `Download fehlgeschlagen (Code ${code ?? status}). Bitte erneut versuchen.`;
}
}