Commit f89e741 1 parent e2c34f1 commit f89e741 Copy full SHA for f89e741
File tree 5 files changed +22
-9
lines changed
5 files changed +22
-9
lines changed Original file line number Diff line number Diff line change @@ -19,3 +19,4 @@ export type Action = {
19
19
[ K in AssetAction ] : { type : K } & ActionMap [ K ] ;
20
20
} [ AssetAction ] ;
21
21
export type OnAction = ( action : Action ) => void ;
22
+ export type PreAction = ( action : Action ) => void ;
Original file line number Diff line number Diff line change 14
14
import { deleteAssets , type AssetResponseDto } from ' @immich/sdk' ;
15
15
import { mdiDeleteForeverOutline , mdiDeleteOutline } from ' @mdi/js' ;
16
16
import { t } from ' svelte-i18n' ;
17
- import type { OnAction } from ' ./action' ;
17
+ import type { OnAction , PreAction } from ' ./action' ;
18
18
19
19
interface Props {
20
20
asset: AssetResponseDto ;
21
21
onAction: OnAction ;
22
+ preAction: PreAction ;
22
23
}
23
24
24
- let { asset, onAction }: Props = $props ();
25
+ let { asset, onAction, preAction }: Props = $props ();
25
26
26
27
let showConfirmModal = $state (false );
27
28
41
42
42
43
const trashAsset = async () => {
43
44
try {
45
+ preAction ({ type: AssetAction .TRASH , asset });
44
46
await deleteAssets ({ assetBulkDeleteDto: { ids: [asset .id ] } });
45
47
onAction ({ type: AssetAction .TRASH , asset });
46
48
Original file line number Diff line number Diff line change 1
1
<script lang =" ts" >
2
2
import { goto } from ' $app/navigation' ;
3
- import type { OnAction } from ' $lib/components/asset-viewer/actions/action' ;
3
+ import type { OnAction , PreAction } from ' $lib/components/asset-viewer/actions/action' ;
4
4
import AddToAlbumAction from ' $lib/components/asset-viewer/actions/add-to-album-action.svelte' ;
5
5
import ArchiveAction from ' $lib/components/asset-viewer/actions/archive-action.svelte' ;
6
6
import CloseAction from ' $lib/components/asset-viewer/actions/close-action.svelte' ;
58
58
showSlideshow? : boolean ;
59
59
onZoomImage: () => void ;
60
60
onCopyImage? : () => Promise <void >;
61
+ preAction: PreAction ;
61
62
onAction: OnAction ;
62
63
onRunJob: (name : AssetJobName ) => void ;
63
64
onPlaySlideshow: () => void ;
76
77
showSlideshow = false ,
77
78
onZoomImage,
78
79
onCopyImage,
80
+ preAction,
79
81
onAction,
80
82
onRunJob,
81
83
onPlaySlideshow,
149
151
{/if} -->
150
152
151
153
{#if isOwner }
152
- <DeleteAction {asset } {onAction } />
154
+ <DeleteAction {asset } {onAction } { preAction } />
153
155
154
156
<ButtonContextMenu direction ="left" align ="top-right" color ="opaque" title ={$t (' more' )} icon ={mdiDotsVertical }>
155
157
{#if showSlideshow }
Original file line number Diff line number Diff line change 1
1
<script lang =" ts" >
2
2
import { focusTrap } from ' $lib/actions/focus-trap' ;
3
- import type { Action , OnAction } from ' $lib/components/asset-viewer/actions/action' ;
3
+ import type { Action , OnAction , PreAction } from ' $lib/components/asset-viewer/actions/action' ;
4
4
import MotionPhotoAction from ' $lib/components/asset-viewer/actions/motion-photo-action.svelte' ;
5
5
import NextAssetAction from ' $lib/components/asset-viewer/actions/next-asset-action.svelte' ;
6
6
import PreviousAssetAction from ' $lib/components/asset-viewer/actions/previous-asset-action.svelte' ;
58
58
isShared? : boolean ;
59
59
album? : AlbumResponseDto | null ;
60
60
person? : PersonResponseDto | null ;
61
+ preAction? : PreAction | undefined ;
61
62
onAction? : OnAction | undefined ;
62
63
reactions? : ActivityResponseDto [];
63
64
onClose: (dto : { asset: AssetResponseDto }) => void ;
75
76
isShared = false ,
76
77
album = null ,
77
78
person = null ,
79
+ preAction = undefined ,
78
80
onAction = undefined ,
79
81
reactions = $bindable ([]),
80
82
onClose,
366
368
const handleStackedAssetMouseEvent = (isMouseOver : boolean , asset : AssetResponseDto ) => {
367
369
previewStackedAsset = isMouseOver ? asset : undefined ;
368
370
};
369
-
371
+ const handlePreAction = (action : Action ) => {
372
+ preAction ?.(action );
373
+ };
370
374
const handleAction = async (action : Action ) => {
371
375
switch (action .type ) {
372
376
case AssetAction .ADD_TO_ALBUM : {
431
435
showSlideshow ={true }
432
436
onZoomImage ={zoomToggle }
433
437
onCopyImage ={copyImage }
438
+ preAction ={handlePreAction }
434
439
onAction ={handleAction }
435
440
onRunJob ={handleRunJob }
436
441
onPlaySlideshow ={() => ($slideshowState = SlideshowState .PlaySlideshow )}
Original file line number Diff line number Diff line change 517
517
518
518
const handleNext = async () => {
519
519
const nextAsset = await $assetStore .getNextAsset ($viewingAsset );
520
-
521
520
if (nextAsset ) {
522
521
const preloadAsset = await $assetStore .getNextAsset (nextAsset );
523
522
assetViewingStore .setAsset (nextAsset , preloadAsset ? [preloadAsset ] : []);
546
545
await navigate ({ targetRoute: ' current' , assetId: null , assetGridRouteSearchParams: $gridScrollTarget });
547
546
};
548
547
549
- const handleAction = async (action : Action ) => {
548
+ const handlePreAction = async (action : Action ) => {
550
549
switch (action .type ) {
551
550
case removeAction :
552
551
case AssetAction .TRASH :
560
559
assetStore .removeAssets ([action .asset .id ]);
561
560
break ;
562
561
}
563
-
562
+ }
563
+ };
564
+ const handleAction = (action : Action ) => {
565
+ switch (action .type ) {
564
566
case AssetAction .ARCHIVE :
565
567
case AssetAction .UNARCHIVE :
566
568
case AssetAction .FAVORITE :
928
930
{isShared }
929
931
{album }
930
932
{person }
933
+ preAction ={handlePreAction }
931
934
onAction ={handleAction }
932
935
onPrevious ={handlePrevious }
933
936
onNext ={handleNext }
You can’t perform that action at this time.
0 commit comments