fix: skip inaccessible album grants in global search
This commit is contained in:
1 parent
abe072b2d1
commit
bdf6399b35
2 files changed
+17
-1
No files matched your search
@@ -112,6 +112,20 @@ test("moves the queried granted album to the active gallery context without losi
|
|||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("global search keeps hits when a granted album is no longer visible in Immich", async () => {
|
||||||
|
const { catalog, immich } = createCatalog({ grantedAlbumIds: ["allowed", "missing"] });
|
||||||
|
immich.searchPhotos.mockImplementation(async ({ albumIds: [id] }) => {
|
||||||
|
if (id === "missing") throw new Error("Album no longer accessible");
|
||||||
|
return {
|
||||||
|
items: [{ id: `photo-${id}`, albums: [] }],
|
||||||
|
total: 1, nextPage: null, previousPage: null,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = await catalog.searchVisiblePhotos("editorial-1", { description: "hsv" });
|
||||||
|
expect(result.items.map(({ id }) => id)).toEqual(["photo-allowed"]);
|
||||||
|
});
|
||||||
|
|
||||||
test("does not call Immich when an editorial has no current album grants", async () => {
|
test("does not call Immich when an editorial has no current album grants", async () => {
|
||||||
const { catalog, immich } = createCatalog({ grantedAlbumIds: [] });
|
const { catalog, immich } = createCatalog({ grantedAlbumIds: [] });
|
||||||
|
|
||||||
|
|||||||
@@ -91,8 +91,10 @@ export function createAlbumCatalog({ grants, immich, consumeRateLimit: consume }
|
|||||||
// grant count and narrowed by the description filter, so per-album results
|
// grant count and narrowed by the description filter, so per-album results
|
||||||
// are small. If a huge-grant editorial makes this slow, cap the fan-out
|
// are small. If a huge-grant editorial makes this slow, cap the fan-out
|
||||||
// and accept partial coverage.
|
// and accept partial coverage.
|
||||||
|
const visibleIds = new Set((await loadAlbums(immich)).map(({ id }) => id));
|
||||||
const pages = await Promise.all(
|
const pages = await Promise.all(
|
||||||
grantedAlbumIds.map((albumId) => searchAlbum(immich, [albumId], description, page, size)),
|
grantedAlbumIds.filter((id) => visibleIds.has(id))
|
||||||
|
.map((albumId) => searchAlbum(immich, [albumId], description, page, size)),
|
||||||
);
|
);
|
||||||
return mergeSearchPages(pages);
|
return mergeSearchPages(pages);
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in new issue
Block a user