mirror of
https://github.com/immich-app/immich
synced 2026-08-15 13:03:57 +00:00
feat(web): search album description in add-to-album modal (#30462)
Co-authored-by: Daniel Dietzler <36593685+danieldietzler@users.noreply.github.com>
This commit is contained in:
parent
4082fbf232
commit
da7d8c2e12
3 changed files with 21 additions and 1 deletions
|
|
@ -40,6 +40,9 @@
|
|||
const albumNameArray: string[] = $derived.by(() => {
|
||||
let { albumName } = album;
|
||||
let findIndex = normalizeSearchString(albumName).indexOf(normalizeSearchString(searchQuery));
|
||||
if (findIndex === -1) {
|
||||
return [albumName, '', ''];
|
||||
}
|
||||
let findLength = searchQuery.length;
|
||||
return [
|
||||
albumName.slice(0, findIndex),
|
||||
|
|
|
|||
|
|
@ -108,6 +108,19 @@ describe('Album Modal', () => {
|
|||
]);
|
||||
});
|
||||
|
||||
it('search matches on description as well as name', () => {
|
||||
const converter = new AlbumModalRowConverter(AlbumSortBy.MostRecentPhoto, SortOrder.Desc);
|
||||
const holidayAlbum = albumFactory.build({ albumName: 'Vacances 2019', description: 'Crete' });
|
||||
const constructionAlbum = albumFactory.build({ albumName: 'Construction' });
|
||||
const modalRows = converter.toModalRows('Crete', [], [holidayAlbum, constructionAlbum], -1, []);
|
||||
|
||||
expect(modalRows).toStrictEqual([
|
||||
createNewAlbumRow(false),
|
||||
createSectionRow('ALBUMS'),
|
||||
createAlbumRow(holidayAlbum, false),
|
||||
]);
|
||||
});
|
||||
|
||||
it('selection can select new album row', () => {
|
||||
const converter = new AlbumModalRowConverter(AlbumSortBy.MostRecentPhoto, SortOrder.Desc);
|
||||
const holidayAlbum = albumFactory.build({ albumName: 'Holidays' });
|
||||
|
|
|
|||
|
|
@ -46,10 +46,14 @@ export class AlbumModalRowConverter {
|
|||
const recentAlbumsToShow = search.length === 0 ? recentAlbums : [];
|
||||
const rows: AlbumModalRow[] = [{ type: AlbumModalRowType.NEW_ALBUM, selected: selectedRowIndex === 0 }];
|
||||
|
||||
const normalizedSearch = normalizeSearchString(search);
|
||||
const filteredAlbums = sortAlbums(
|
||||
search.length > 0 && albums.length > 0
|
||||
? albums.filter((album) => {
|
||||
return normalizeSearchString(album.albumName).includes(normalizeSearchString(search));
|
||||
return (
|
||||
normalizeSearchString(album.albumName).includes(normalizedSearch) ||
|
||||
normalizeSearchString(album.description).includes(normalizedSearch)
|
||||
);
|
||||
})
|
||||
: albums,
|
||||
{ sortBy: this.sortBy, orderBy: this.orderBy },
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue