diff --git a/src/modules/albums/catalog-content.test.tsx b/src/modules/albums/catalog-content.test.tsx
index 887ce28..0b33b46 100644
--- a/src/modules/albums/catalog-content.test.tsx
+++ b/src/modules/albums/catalog-content.test.tsx
@@ -1,6 +1,6 @@
// @vitest-environment jsdom
-import { cleanup, fireEvent, render, screen } from "@testing-library/react";
+import { cleanup, fireEvent, render, screen, within } from "@testing-library/react";
import { afterEach, expect, test } from "vitest";
import { AlbumContactSheet } from "./catalog-content";
@@ -83,6 +83,25 @@ test("renders the server-scoped download choices for a catalog photo", () => {
expect(screen.getByRole("button", { name: /original laden/i })).not.toBeNull();
});
+test("offers the existing download workflow on a global search result and its lightbox", () => {
+ render(
+ ,
+ );
+
+ expect(screen.getByRole("button", { name: /original laden/i })).not.toBeNull();
+ fireEvent.click(screen.getByRole("button", { name: /tor-des-sieges\.jpg vergrößern/i }));
+ expect(within(screen.getByRole("dialog")).getByRole("button", { name: /original laden/i })).not.toBeNull();
+});
+
test("opens a full-screen lightbox when a photo tile is clicked", () => {
render(
{
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();
-});
\ No newline at end of file
+});
diff --git a/src/modules/albums/catalog.test.ts b/src/modules/albums/catalog.test.ts
index 8f13eb8..598cff8 100644
--- a/src/modules/albums/catalog.test.ts
+++ b/src/modules/albums/catalog.test.ts
@@ -62,6 +62,28 @@ test("uses a requested album only when it is in the current editorial grants", a
);
});
+test("restores the queried granted album when Immich omits an asset album association", async () => {
+ const { catalog, immich } = createCatalog({ grantedAlbumIds: ["allowed"] });
+ immich.searchPhotos.mockResolvedValue({
+ items: [{
+ id: "asset-1",
+ type: "IMAGE",
+ originalFileName: "tor.jpg",
+ originalMimeType: "image/jpeg",
+ localDateTime: null,
+ fileCreatedAt: null,
+ albums: [],
+ }],
+ total: 1,
+ nextPage: null,
+ previousPage: null,
+ });
+
+ const result = await catalog.searchVisiblePhotos("editorial-1", { page: 1 });
+
+ expect(result.items[0]?.albums).toEqual([{ id: "allowed" }]);
+});
+
test("does not call Immich when an editorial has no current album grants", async () => {
const { catalog, immich } = createCatalog({ grantedAlbumIds: [] });
diff --git a/src/modules/albums/catalog.ts b/src/modules/albums/catalog.ts
index 2491245..ec1c49f 100644
--- a/src/modules/albums/catalog.ts
+++ b/src/modules/albums/catalog.ts
@@ -107,13 +107,22 @@ async function searchAlbum(
size: number,
): Promise {
try {
- return await immich.searchPhotos({
+ const searchPage = await immich.searchPhotos({
albumIds,
...(description === undefined ? {} : { description }),
type: "IMAGE",
page,
size,
});
+ const queriedAlbumId = albumIds[0];
+ return {
+ ...searchPage,
+ items: queriedAlbumId
+ ? searchPage.items.map((asset) => asset.albums.some(({ id }) => id === queriedAlbumId)
+ ? asset
+ : { ...asset, albums: [{ id: queriedAlbumId }, ...asset.albums] })
+ : searchPage.items,
+ };
} catch {
throw new AlbumCatalogError("IMMICH_UNAVAILABLE");
}