mirror of
https://github.com/immich-app/immich.git
synced 2025-01-16 16:56:46 +01:00
fix: web search add to album reactivity (#13539)
This commit is contained in:
parent
57704ba5a7
commit
6b2f23b5a3
3 changed files with 17 additions and 3 deletions
|
@ -6,8 +6,10 @@
|
||||||
import { getAssetControlContext } from '../asset-select-control-bar.svelte';
|
import { getAssetControlContext } from '../asset-select-control-bar.svelte';
|
||||||
import { mdiImageAlbum, mdiShareVariantOutline } from '@mdi/js';
|
import { mdiImageAlbum, mdiShareVariantOutline } from '@mdi/js';
|
||||||
import { t } from 'svelte-i18n';
|
import { t } from 'svelte-i18n';
|
||||||
|
import type { OnAddToAlbum } from '$lib/utils/actions';
|
||||||
|
|
||||||
export let shared = false;
|
export let shared = false;
|
||||||
|
export let onAddToAlbum: OnAddToAlbum = () => {};
|
||||||
|
|
||||||
let showAlbumPicker = false;
|
let showAlbumPicker = false;
|
||||||
|
|
||||||
|
@ -21,13 +23,19 @@
|
||||||
showAlbumPicker = false;
|
showAlbumPicker = false;
|
||||||
|
|
||||||
const assetIds = [...getAssets()].map((asset) => asset.id);
|
const assetIds = [...getAssets()].map((asset) => asset.id);
|
||||||
await addAssetsToNewAlbum(albumName, assetIds);
|
const album = await addAssetsToNewAlbum(albumName, assetIds);
|
||||||
|
if (!album) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
onAddToAlbum(assetIds, album.id);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleAddToAlbum = async (album: AlbumResponseDto) => {
|
const handleAddToAlbum = async (album: AlbumResponseDto) => {
|
||||||
showAlbumPicker = false;
|
showAlbumPicker = false;
|
||||||
const assetIds = [...getAssets()].map((asset) => asset.id);
|
const assetIds = [...getAssets()].map((asset) => asset.id);
|
||||||
await addAssetsToAlbum(album.id, assetIds);
|
await addAssetsToAlbum(album.id, assetIds);
|
||||||
|
onAddToAlbum(assetIds, album.id);
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ export type OnDelete = (assetIds: string[]) => void;
|
||||||
export type OnRestore = (ids: string[]) => void;
|
export type OnRestore = (ids: string[]) => void;
|
||||||
export type OnLink = (assets: { still: AssetResponseDto; motion: AssetResponseDto }) => void;
|
export type OnLink = (assets: { still: AssetResponseDto; motion: AssetResponseDto }) => void;
|
||||||
export type OnUnlink = (assets: { still: AssetResponseDto; motion: AssetResponseDto }) => void;
|
export type OnUnlink = (assets: { still: AssetResponseDto; motion: AssetResponseDto }) => void;
|
||||||
|
export type OnAddToAlbum = (ids: string[], albumId: string) => void;
|
||||||
export type OnArchive = (ids: string[], isArchived: boolean) => void;
|
export type OnArchive = (ids: string[], isArchived: boolean) => void;
|
||||||
export type OnFavorite = (ids: string[], favorite: boolean) => void;
|
export type OnFavorite = (ids: string[], favorite: boolean) => void;
|
||||||
export type OnStack = (ids: string[]) => void;
|
export type OnStack = (ids: string[]) => void;
|
||||||
|
|
|
@ -216,6 +216,11 @@
|
||||||
|
|
||||||
const triggerAssetUpdate = () => (searchResultAssets = searchResultAssets);
|
const triggerAssetUpdate = () => (searchResultAssets = searchResultAssets);
|
||||||
|
|
||||||
|
const onAddToAlbum = (assetIds: string[]) => {
|
||||||
|
const assetIdSet = new Set(assetIds);
|
||||||
|
searchResultAssets = searchResultAssets.filter((a: AssetResponseDto) => !assetIdSet.has(a.id));
|
||||||
|
};
|
||||||
|
|
||||||
function getObjectKeys<T extends object>(obj: T): (keyof T)[] {
|
function getObjectKeys<T extends object>(obj: T): (keyof T)[] {
|
||||||
return Object.keys(obj) as (keyof T)[];
|
return Object.keys(obj) as (keyof T)[];
|
||||||
}
|
}
|
||||||
|
@ -230,8 +235,8 @@
|
||||||
<CreateSharedLink />
|
<CreateSharedLink />
|
||||||
<CircleIconButton title={$t('select_all')} icon={mdiSelectAll} on:click={handleSelectAll} />
|
<CircleIconButton title={$t('select_all')} icon={mdiSelectAll} on:click={handleSelectAll} />
|
||||||
<ButtonContextMenu icon={mdiPlus} title={$t('add_to')}>
|
<ButtonContextMenu icon={mdiPlus} title={$t('add_to')}>
|
||||||
<AddToAlbum />
|
<AddToAlbum {onAddToAlbum} />
|
||||||
<AddToAlbum shared />
|
<AddToAlbum shared {onAddToAlbum} />
|
||||||
</ButtonContextMenu>
|
</ButtonContextMenu>
|
||||||
<FavoriteAction removeFavorite={isAllFavorite} onFavorite={triggerAssetUpdate} />
|
<FavoriteAction removeFavorite={isAllFavorite} onFavorite={triggerAssetUpdate} />
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue