1
0
mirror of https://github.com/immich-app/immich.git synced 2025-06-27 05:11:11 +02:00

refactor(web): asset viewer actions (#5488)

This commit is contained in:
Jason Rasmussen
2023-12-04 19:18:28 -05:00
committed by GitHub
parent 56aed8246d
commit 22d79850f6
3 changed files with 33 additions and 30 deletions

View File

@ -19,7 +19,7 @@
import PhotoViewer from './photo-viewer.svelte';
import VideoViewer from './video-viewer.svelte';
import PanoramaViewer from './panorama-viewer.svelte';
import { ProjectionType } from '$lib/constants';
import { AssetAction, ProjectionType } from '$lib/constants';
import ConfirmDialogue from '$lib/components/shared-components/confirm-dialogue.svelte';
import ProfileImageCropper from '../shared-components/profile-image-cropper.svelte';
import { isShowDetail } from '$lib/stores/preferences.store';
@ -64,14 +64,10 @@
} = slideshowStore;
const dispatch = createEventDispatcher<{
archived: AssetResponseDto;
unarchived: AssetResponseDto;
favorite: AssetResponseDto;
unfavorite: AssetResponseDto;
action: { type: AssetAction; asset: AssetResponseDto };
close: void;
next: void;
previous: void;
unstack: void;
}>();
let appearsInAlbums: AlbumResponseDto[] = [];
@ -374,9 +370,7 @@
try {
await api.assetApi.deleteAssets({ assetBulkDeleteDto: { ids: [asset.id] } });
await navigateAssetForward();
assetStore?.removeAsset(asset.id);
dispatch('action', { type: AssetAction.TRASH, asset });
notificationController.show({
message: 'Moved to trash',
@ -391,9 +385,7 @@
try {
await api.assetApi.deleteAssets({ assetBulkDeleteDto: { ids: [asset.id], force: true } });
await navigateAssetForward();
assetStore?.removeAsset(asset.id);
dispatch('action', { type: AssetAction.DELETE, asset });
notificationController.show({
message: 'Permanently deleted asset',
@ -416,8 +408,7 @@
});
asset.isFavorite = data.isFavorite;
assetStore?.updateAsset(data);
dispatch(data.isFavorite ? 'favorite' : 'unfavorite', data);
dispatch('action', { type: data.isFavorite ? AssetAction.FAVORITE : AssetAction.UNFAVORITE, asset: data });
notificationController.show({
type: NotificationType.Info,
@ -473,8 +464,7 @@
});
asset.isArchived = data.isArchived;
assetStore?.updateAsset(data);
dispatch(data.isArchived ? 'archived' : 'unarchived', data);
dispatch('action', { type: data.isArchived ? AssetAction.ARCHIVE : AssetAction.UNARCHIVE, asset: data });
notificationController.show({
type: NotificationType.Info,
@ -557,10 +547,10 @@
child.stackParentId = null;
child.stackCount = 0;
child.stack = [];
assetStore?.addAsset(child);
dispatch('action', { type: AssetAction.ADD, asset: child });
}
dispatch('unstack');
dispatch('close');
notificationController.show({ type: NotificationType.Info, message: 'Un-stacked', timeout: 1500 });
} catch (error) {
await handleError(error, `Unable to unstack`);