feat: redesign dashboard, add lightbox bulk download, and standardize ui

This commit is contained in:
Leon Tonhäuser committed 2026-08-11 11:18:39 +02:00
1 parent 8728308fc6
commit 4a9da65901
13 files changed
+923 -104

No files matched your search

+37 -44
View File
@@ -92,22 +92,15 @@ function createRepository() {
function createService() {
const state = createRepository();
const immich = {
listAlbumsForAsset: vi.fn().mockResolvedValue([
{
id: albumId,
albumName: "Presse 2026",
description: null,
albumThumbnailAssetId: assetId,
assetCount: 1,
},
]),
getAlbum: vi.fn().mockResolvedValue({
id: albumId,
albumName: "Presse 2026",
}),
getAsset: vi.fn().mockResolvedValue({
id: assetId,
type: "IMAGE" as const,
originalFileName: "jubel.jpg",
originalMimeType: "image/jpeg",
localDateTime: null,
fileCreatedAt: null,
albums: [{ id: albumId }],
}),
};
@@ -231,63 +224,63 @@ test.each([
}),
).rejects.toMatchObject({ code });
expect(findIntent).not.toHaveBeenCalled();
expect(immich.listAlbumsForAsset).not.toHaveBeenCalled();
expect(immich.getAsset).not.toHaveBeenCalled();
expect(immich.getAlbum).not.toHaveBeenCalled();
},
);
test("rejects an asset outside the exact requested album", async () => {
const { service, immich, usages } = createService();
immich.listAlbumsForAsset.mockResolvedValue([
{
id: otherAlbumId,
albumName: "Andere Bilder",
description: null,
albumThumbnailAssetId: null,
assetCount: 1,
},
]);
immich.getAsset.mockResolvedValue({
id: assetId,
type: "IMAGE" as const,
originalFileName: "jubel.jpg",
originalMimeType: "image/jpeg",
albums: [{ id: otherAlbumId }],
});
await expect(service.createNewUsage(newUsageInput)).rejects.toMatchObject({
code: "ASSET_NOT_IN_ALBUM",
});
expect(immich.getAsset).not.toHaveBeenCalled();
expect(immich.getAlbum).not.toHaveBeenCalled();
expect(usages).toHaveLength(0);
});
test("rejects removal from the requested album between preflight and locked refresh", async () => {
const { service, immich, usages } = createService();
immich.listAlbumsForAsset
.mockResolvedValueOnce([
{
id: albumId,
albumName: "Presse 2026",
description: null,
albumThumbnailAssetId: assetId,
assetCount: 1,
},
])
.mockResolvedValueOnce([]);
immich.getAsset
.mockResolvedValueOnce({
id: assetId,
type: "IMAGE" as const,
originalFileName: "jubel.jpg",
originalMimeType: "image/jpeg",
albums: [{ id: albumId }],
})
.mockResolvedValueOnce({
id: assetId,
type: "IMAGE" as const,
originalFileName: "jubel.jpg",
originalMimeType: "image/jpeg",
albums: [],
});
await expect(service.createNewUsage(newUsageInput)).rejects.toMatchObject({
code: "ASSET_NOT_IN_ALBUM",
});
expect(immich.listAlbumsForAsset).toHaveBeenCalledTimes(2);
expect(immich.getAsset).toHaveBeenCalledTimes(2);
expect(usages).toHaveLength(0);
});
test("persists metadata from the locked final Immich refresh", async () => {
const { service, immich, usages } = createService();
immich.listAlbumsForAsset
.mockResolvedValueOnce([
{
id: albumId,
albumName: "Presse 2026",
description: null,
albumThumbnailAssetId: assetId,
assetCount: 1,
},
])
immich.getAsset
.mockResolvedValueOnce({
id: assetId,
type: "IMAGE" as const,
originalFileName: "jubel.jpg",
originalMimeType: "image/jpeg",
albums: [{ id: albumId }],
})
.mockResolvedValueOnce([
{
id: albumId,
+19 -7
View File
@@ -57,11 +57,13 @@ export type UsageRepository = {
};
type UsageImmich = {
listAlbumsForAsset(assetId: string): Promise<ImmichAlbumSummary[]>;
getAlbum(albumId: string): Promise<{ id: string; albumName: string }>;
getAsset(assetId: string): Promise<{
id: string;
type: string;
originalFileName: string;
originalMimeType: string;
type: string;
albums: Array<{ id: string }>;
}>;
};
@@ -330,15 +332,25 @@ async function loadRequestedAlbum(
immich: UsageImmich,
assetId: string,
albumId: string,
): Promise<ImmichAlbumSummary> {
let albums: ImmichAlbumSummary[];
): Promise<{ id: string; albumName: string }> {
let asset;
try {
albums = await immich.listAlbumsForAsset(assetId);
asset = await immich.getAsset(assetId);
} catch {
throw new UsageAccountingError("IMMICH_UNAVAILABLE");
}
const album = albums.find((candidate) => candidate.id === albumId);
if (!album) throw new UsageAccountingError("ASSET_NOT_IN_ALBUM");
if (!asset.albums.some((a) => a.id === albumId)) {
throw new UsageAccountingError("ASSET_NOT_IN_ALBUM");
}
let album;
try {
album = await immich.getAlbum(albumId);
} catch {
throw new UsageAccountingError("IMMICH_UNAVAILABLE");
}
return album;
}