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:
1 parent
a3ec068cac
commit
a7df6bd60a
4 files changed
+103
-57
No files matched your search
+40
-39
@@ -569,73 +569,74 @@ a {
|
||||
text-underline-offset: 0.2em;
|
||||
}
|
||||
|
||||
.album-contact-sheet {
|
||||
/* --- Album overview: grid of cover tiles in the photo-gallery aesthetic ---
|
||||
Cover images use object-fit: cover with a consistent 4/3 tile (album
|
||||
summaries don't carry EXIF, so no native per-cover aspect ratio), a
|
||||
persistent bottom gradient with album name + photo count, and a hover
|
||||
zoom. Clicking opens the album. Mirrors the photo grid's hover language. */
|
||||
.album-gallery {
|
||||
display: grid;
|
||||
gap: clamp(1.25rem, 2.25vw, 2.5rem);
|
||||
gap: clamp(0.75rem, 1.5vw, 1.25rem);
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
grid-template-columns: repeat(auto-fill, minmax(min(100%, 18rem), 1fr));
|
||||
grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr));
|
||||
}
|
||||
|
||||
.contact-sheet-link {
|
||||
.album-tile {
|
||||
display: block;
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.album-contact-frame {
|
||||
.album-tile-frame {
|
||||
position: relative;
|
||||
margin: 0;
|
||||
background: var(--contact-sheet);
|
||||
border: 1px solid var(--ink);
|
||||
overflow: hidden;
|
||||
background: var(--contact-sheet);
|
||||
aspect-ratio: 4 / 3;
|
||||
}
|
||||
|
||||
.contact-sheet-image,
|
||||
.missing-contact-image {
|
||||
.album-tile-image {
|
||||
display: block;
|
||||
width: 100%;
|
||||
aspect-ratio: 3 / 2;
|
||||
object-fit: contain;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
background: var(--contact-sheet);
|
||||
transition: transform 150ms ease-out;
|
||||
transition: transform 200ms ease-out;
|
||||
}
|
||||
|
||||
.missing-contact-image {
|
||||
.album-tile-missing {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
color: var(--metadata);
|
||||
font-size: 0.75rem;
|
||||
font-size: 0.7rem;
|
||||
letter-spacing: 0.08em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.contact-sheet-link:hover .contact-sheet-image,
|
||||
.contact-sheet-link:focus-visible .contact-sheet-image {
|
||||
transform: scale(1.015);
|
||||
.album-tile:hover .album-tile-image,
|
||||
.album-tile:focus-visible .album-tile-image {
|
||||
transform: scale(1.03);
|
||||
}
|
||||
|
||||
.contact-strip {
|
||||
/* Persistent overlay (unlike the photo grid's hover-only overlay) — album
|
||||
names need to be readable at a glance so editors can pick one. */
|
||||
.album-tile-overlay {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
justify-content: space-between;
|
||||
gap: 0.75rem;
|
||||
min-height: 2.35rem;
|
||||
margin: 0;
|
||||
padding: 0.5rem 0.625rem;
|
||||
border-top: 1px solid var(--ink);
|
||||
background: var(--contact-sheet);
|
||||
color: var(--graphite);
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
||||
font-size: 0.625rem;
|
||||
letter-spacing: 0.035em;
|
||||
line-height: 1.25;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.contact-strip-name {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
flex-direction: column;
|
||||
justify-content: flex-end;
|
||||
padding: 0.75rem;
|
||||
background: linear-gradient(
|
||||
to top,
|
||||
rgb(0 0 0 / 85%) 0%,
|
||||
rgb(0 0 0 / 30%) 55%,
|
||||
rgb(0 0 0 / 0%) 85%
|
||||
);
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
/* --- Photo overview: masonry grid + hover overlay + lightbox --------------
|
||||
@@ -1152,7 +1153,7 @@ a {
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.contact-sheet-image,
|
||||
.album-tile-image,
|
||||
.photo-tile-image,
|
||||
.photo-tile-overlay {
|
||||
transition: none;
|
||||
|
||||
@@ -23,8 +23,12 @@ export function LightboxToggleButton({ assetId, initialInLightbox }: LightboxTog
|
||||
try {
|
||||
const result = await toggleLightboxItem(assetId);
|
||||
setInLightbox(result.isNowInLightbox);
|
||||
} catch {
|
||||
// Revert on error
|
||||
} catch (error) {
|
||||
// Revert the optimistic toggle and surface the real cause. Server
|
||||
// action errors also print to the dev server terminal — check there
|
||||
// for the stack trace. Without this the button just flips back
|
||||
// silently and the user can't tell why the merkzettel "doesn't work".
|
||||
console.error("[merkzettel] toggleLightboxItem failed:", error);
|
||||
setInLightbox(inLightbox);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -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.`;
|
||||
}
|
||||
}
|
||||
@@ -8,29 +8,30 @@ import type { VisibleAlbum } from "./catalog";
|
||||
|
||||
export function AlbumContactSheet({ albums }: Readonly<{ albums: VisibleAlbum[] }>) {
|
||||
return (
|
||||
<ul className="album-contact-sheet" aria-label="Freigegebene Fotoalben">
|
||||
<ul className="album-gallery" aria-label="Freigegebene Fotoalben">
|
||||
{albums.map((album) => (
|
||||
<li key={album.id}>
|
||||
<Link className="contact-sheet-link" href={`/redaktion/alben/${encodeURIComponent(album.id)}`}>
|
||||
<article className="album-contact-frame">
|
||||
<Link className="album-tile" href={`/redaktion/alben/${encodeURIComponent(album.id)}`}>
|
||||
<figure className="album-tile-frame">
|
||||
{album.albumThumbnailAssetId ? (
|
||||
<img
|
||||
alt={`Titelbild: ${album.albumName}`}
|
||||
className="contact-sheet-image"
|
||||
height="480"
|
||||
className="album-tile-image"
|
||||
loading="lazy"
|
||||
src={thumbnailUrl(album.albumThumbnailAssetId)}
|
||||
width="720"
|
||||
/>
|
||||
) : (
|
||||
<div aria-label={`Kein Titelbild für ${album.albumName}`} className="missing-contact-image" role="img">
|
||||
<div aria-label={`Kein Titelbild für ${album.albumName}`} className="album-tile-missing" role="img">
|
||||
Kein Titelbild
|
||||
</div>
|
||||
)}
|
||||
<footer className="contact-strip">
|
||||
<span className="contact-strip-name">{album.albumName}</span>
|
||||
<span>{formatCount(album.assetCount, "Foto")}</span>
|
||||
</footer>
|
||||
</article>
|
||||
<div className="album-tile-overlay">
|
||||
<figcaption className="photo-tile-caption">
|
||||
<span className="photo-tile-name">{album.albumName}</span>
|
||||
<span className="photo-tile-date">{formatCount(album.assetCount, "Foto")}</span>
|
||||
</figcaption>
|
||||
</div>
|
||||
</figure>
|
||||
</Link>
|
||||
</li>
|
||||
))}
|
||||
|
||||
Reference in new issue
Block a user