fix: prioritize authorized search album
This commit is contained in:
1 parent
9aa79cbce9
commit
a3dc56778d
2 files changed
+35
-3
No files matched your search
@@ -84,6 +84,34 @@ test("restores the queried granted album when Immich omits an asset album associ
|
||||
expect(result.items[0]?.albums).toEqual([{ id: "allowed" }]);
|
||||
});
|
||||
|
||||
test("moves the queried granted album to the active gallery context without losing metadata", 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: [
|
||||
{ id: "other", albumName: "Anderes Album" },
|
||||
{ id: "allowed", albumName: "Erlaubtes Album" },
|
||||
],
|
||||
}],
|
||||
total: 1,
|
||||
nextPage: null,
|
||||
previousPage: null,
|
||||
});
|
||||
|
||||
const result = await catalog.searchVisiblePhotos("editorial-1", { page: 1 });
|
||||
|
||||
expect(result.items[0]?.albums).toEqual([
|
||||
{ id: "allowed", albumName: "Erlaubtes Album" },
|
||||
{ id: "other", albumName: "Anderes Album" },
|
||||
]);
|
||||
});
|
||||
|
||||
test("does not call Immich when an editorial has no current album grants", async () => {
|
||||
const { catalog, immich } = createCatalog({ grantedAlbumIds: [] });
|
||||
|
||||
|
||||
@@ -118,9 +118,13 @@ async function searchAlbum(
|
||||
return {
|
||||
...searchPage,
|
||||
items: queriedAlbumId
|
||||
? searchPage.items.map((asset) => asset.albums.some(({ id }) => id === queriedAlbumId)
|
||||
? asset
|
||||
: { ...asset, albums: [{ id: queriedAlbumId }, ...asset.albums] })
|
||||
? searchPage.items.map((asset) => {
|
||||
const queriedAlbum = asset.albums.find(({ id }) => id === queriedAlbumId) ?? { id: queriedAlbumId };
|
||||
return {
|
||||
...asset,
|
||||
albums: [queriedAlbum, ...asset.albums.filter(({ id }) => id !== queriedAlbumId)],
|
||||
};
|
||||
})
|
||||
: searchPage.items,
|
||||
};
|
||||
} catch {
|
||||
|
||||
Reference in new issue
Block a user