mirror of
https://github.com/immich-app/immich.git
synced 2025-07-03 21:40:00 +02:00
feat(web): Implement keep this delete others for asset stacks (#14217)
This commit is contained in:
parent
bcd17c2ebe
commit
1737013e66
7 changed files with 65 additions and 0 deletions
web/src/lib/utils
|
@ -14,6 +14,7 @@ import { getFormatter } from '$lib/utils/i18n';
|
|||
import {
|
||||
addAssetsToAlbum as addAssets,
|
||||
createStack,
|
||||
deleteAssets,
|
||||
deleteStacks,
|
||||
getAssetInfo,
|
||||
getBaseUrl,
|
||||
|
@ -27,6 +28,7 @@ import {
|
|||
type AssetResponseDto,
|
||||
type AssetTypeEnum,
|
||||
type DownloadInfoDto,
|
||||
type StackResponseDto,
|
||||
type UserPreferencesResponseDto,
|
||||
type UserResponseDto,
|
||||
} from '@immich/sdk';
|
||||
|
@ -438,6 +440,26 @@ export const deleteStack = async (stackIds: string[]) => {
|
|||
}
|
||||
};
|
||||
|
||||
export const keepThisDeleteOthers = async (keepAsset: AssetResponseDto, stack: StackResponseDto) => {
|
||||
const $t = get(t);
|
||||
|
||||
try {
|
||||
const assetsToDeleteIds = stack.assets.filter((asset) => asset.id !== keepAsset.id).map((asset) => asset.id);
|
||||
await deleteAssets({ assetBulkDeleteDto: { ids: assetsToDeleteIds } });
|
||||
await deleteStacks({ bulkIdsDto: { ids: [stack.id] } });
|
||||
|
||||
notificationController.show({
|
||||
type: NotificationType.Info,
|
||||
message: $t('kept_this_deleted_others', { values: { count: assetsToDeleteIds.length } }),
|
||||
});
|
||||
|
||||
keepAsset.stack = null;
|
||||
return keepAsset;
|
||||
} catch (error) {
|
||||
handleError(error, $t('errors.failed_to_keep_this_delete_others'));
|
||||
}
|
||||
};
|
||||
|
||||
export const selectAllAssets = async (assetStore: AssetStore, assetInteractionStore: AssetInteractionStore) => {
|
||||
if (get(isSelectingAllAssets)) {
|
||||
// Selection is already ongoing
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue