feat(web): Implement keep this delete others for asset stacks ()

This commit is contained in:
Braydon Davis 2024-11-19 09:54:35 -07:00 committed by GitHub
parent bcd17c2ebe
commit 1737013e66
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 65 additions and 0 deletions
web/src/lib/utils

View file

@ -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