Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions web/src/lib/components/asset-viewer/actions/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ export type Action = {
[K in AssetAction]: { type: K } & ActionMap[K];
}[AssetAction];
export type OnAction = (action: Action) => void;
export type PreAction = (action: Action) => void;
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@
import { deleteAssets, type AssetResponseDto } from '@immich/sdk';
import { mdiDeleteForeverOutline, mdiDeleteOutline } from '@mdi/js';
import { t } from 'svelte-i18n';
import type { OnAction } from './action';
import type { OnAction, PreAction } from './action';

interface Props {
asset: AssetResponseDto;
onAction: OnAction;
preAction: PreAction;
}

let { asset, onAction }: Props = $props();
let { asset, onAction, preAction }: Props = $props();

let showConfirmModal = $state(false);

Expand All @@ -41,6 +42,7 @@

const trashAsset = async () => {
try {
preAction({ type: AssetAction.TRASH, asset });
await deleteAssets({ assetBulkDeleteDto: { ids: [asset.id] } });
onAction({ type: AssetAction.TRASH, asset });

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import { goto } from '$app/navigation';
import type { OnAction } from '$lib/components/asset-viewer/actions/action';
import type { OnAction, PreAction } from '$lib/components/asset-viewer/actions/action';
import AddToAlbumAction from '$lib/components/asset-viewer/actions/add-to-album-action.svelte';
import ArchiveAction from '$lib/components/asset-viewer/actions/archive-action.svelte';
import CloseAction from '$lib/components/asset-viewer/actions/close-action.svelte';
Expand Down Expand Up @@ -58,6 +58,7 @@
showSlideshow?: boolean;
onZoomImage: () => void;
onCopyImage?: () => Promise<void>;
preAction: PreAction;
onAction: OnAction;
onRunJob: (name: AssetJobName) => void;
onPlaySlideshow: () => void;
Expand All @@ -76,6 +77,7 @@
showSlideshow = false,
onZoomImage,
onCopyImage,
preAction,
onAction,
onRunJob,
onPlaySlideshow,
Expand Down Expand Up @@ -149,7 +151,7 @@
{/if} -->

{#if isOwner}
<DeleteAction {asset} {onAction} />
<DeleteAction {asset} {onAction} {preAction} />

<ButtonContextMenu direction="left" align="top-right" color="opaque" title={$t('more')} icon={mdiDotsVertical}>
{#if showSlideshow}
Expand Down
9 changes: 7 additions & 2 deletions web/src/lib/components/asset-viewer/asset-viewer.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import { focusTrap } from '$lib/actions/focus-trap';
import type { Action, OnAction } from '$lib/components/asset-viewer/actions/action';
import type { Action, OnAction, PreAction } from '$lib/components/asset-viewer/actions/action';
import MotionPhotoAction from '$lib/components/asset-viewer/actions/motion-photo-action.svelte';
import NextAssetAction from '$lib/components/asset-viewer/actions/next-asset-action.svelte';
import PreviousAssetAction from '$lib/components/asset-viewer/actions/previous-asset-action.svelte';
Expand Down Expand Up @@ -58,6 +58,7 @@
isShared?: boolean;
album?: AlbumResponseDto | null;
person?: PersonResponseDto | null;
preAction?: PreAction | undefined;
onAction?: OnAction | undefined;
reactions?: ActivityResponseDto[];
onClose: (dto: { asset: AssetResponseDto }) => void;
Expand All @@ -75,6 +76,7 @@
isShared = false,
album = null,
person = null,
preAction = undefined,
onAction = undefined,
reactions = $bindable([]),
onClose,
Expand Down Expand Up @@ -366,7 +368,9 @@
const handleStackedAssetMouseEvent = (isMouseOver: boolean, asset: AssetResponseDto) => {
previewStackedAsset = isMouseOver ? asset : undefined;
};

const handlePreAction = (action: Action) => {
preAction?.(action);
};
const handleAction = async (action: Action) => {
switch (action.type) {
case AssetAction.ADD_TO_ALBUM: {
Expand Down Expand Up @@ -431,6 +435,7 @@
showSlideshow={true}
onZoomImage={zoomToggle}
onCopyImage={copyImage}
preAction={handlePreAction}
onAction={handleAction}
onRunJob={handleRunJob}
onPlaySlideshow={() => ($slideshowState = SlideshowState.PlaySlideshow)}
Expand Down
9 changes: 6 additions & 3 deletions web/src/lib/components/photos-page/asset-grid.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,6 @@

const handleNext = async () => {
const nextAsset = await $assetStore.getNextAsset($viewingAsset);

if (nextAsset) {
const preloadAsset = await $assetStore.getNextAsset(nextAsset);
assetViewingStore.setAsset(nextAsset, preloadAsset ? [preloadAsset] : []);
Expand Down Expand Up @@ -546,7 +545,7 @@
await navigate({ targetRoute: 'current', assetId: null, assetGridRouteSearchParams: $gridScrollTarget });
};

const handleAction = async (action: Action) => {
const handlePreAction = async (action: Action) => {
switch (action.type) {
case removeAction:
case AssetAction.TRASH:
Expand All @@ -560,7 +559,10 @@
assetStore.removeAssets([action.asset.id]);
break;
}

}
};
const handleAction = (action: Action) => {
switch (action.type) {
case AssetAction.ARCHIVE:
case AssetAction.UNARCHIVE:
case AssetAction.FAVORITE:
Expand Down Expand Up @@ -928,6 +930,7 @@
{isShared}
{album}
{person}
preAction={handlePreAction}
onAction={handleAction}
onPrevious={handlePrevious}
onNext={handleNext}
Expand Down
Loading