mirror of
https://github.com/immich-app/immich.git
synced 2025-05-24 01:12:58 -04:00
fix(web): delete action closes asset viewer in asset view (#15469)
fixes #14647
This commit is contained in:
parent
e2c34f17ba
commit
f89e74181b
@ -19,3 +19,4 @@ export type Action = {
|
|||||||
[K in AssetAction]: { type: K } & ActionMap[K];
|
[K in AssetAction]: { type: K } & ActionMap[K];
|
||||||
}[AssetAction];
|
}[AssetAction];
|
||||||
export type OnAction = (action: Action) => void;
|
export type OnAction = (action: Action) => void;
|
||||||
|
export type PreAction = (action: Action) => void;
|
||||||
|
@ -14,14 +14,15 @@
|
|||||||
import { deleteAssets, type AssetResponseDto } from '@immich/sdk';
|
import { deleteAssets, type AssetResponseDto } from '@immich/sdk';
|
||||||
import { mdiDeleteForeverOutline, mdiDeleteOutline } from '@mdi/js';
|
import { mdiDeleteForeverOutline, mdiDeleteOutline } from '@mdi/js';
|
||||||
import { t } from 'svelte-i18n';
|
import { t } from 'svelte-i18n';
|
||||||
import type { OnAction } from './action';
|
import type { OnAction, PreAction } from './action';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
asset: AssetResponseDto;
|
asset: AssetResponseDto;
|
||||||
onAction: OnAction;
|
onAction: OnAction;
|
||||||
|
preAction: PreAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
let { asset, onAction }: Props = $props();
|
let { asset, onAction, preAction }: Props = $props();
|
||||||
|
|
||||||
let showConfirmModal = $state(false);
|
let showConfirmModal = $state(false);
|
||||||
|
|
||||||
@ -41,6 +42,7 @@
|
|||||||
|
|
||||||
const trashAsset = async () => {
|
const trashAsset = async () => {
|
||||||
try {
|
try {
|
||||||
|
preAction({ type: AssetAction.TRASH, asset });
|
||||||
await deleteAssets({ assetBulkDeleteDto: { ids: [asset.id] } });
|
await deleteAssets({ assetBulkDeleteDto: { ids: [asset.id] } });
|
||||||
onAction({ type: AssetAction.TRASH, asset });
|
onAction({ type: AssetAction.TRASH, asset });
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { goto } from '$app/navigation';
|
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 AddToAlbumAction from '$lib/components/asset-viewer/actions/add-to-album-action.svelte';
|
||||||
import ArchiveAction from '$lib/components/asset-viewer/actions/archive-action.svelte';
|
import ArchiveAction from '$lib/components/asset-viewer/actions/archive-action.svelte';
|
||||||
import CloseAction from '$lib/components/asset-viewer/actions/close-action.svelte';
|
import CloseAction from '$lib/components/asset-viewer/actions/close-action.svelte';
|
||||||
@ -58,6 +58,7 @@
|
|||||||
showSlideshow?: boolean;
|
showSlideshow?: boolean;
|
||||||
onZoomImage: () => void;
|
onZoomImage: () => void;
|
||||||
onCopyImage?: () => Promise<void>;
|
onCopyImage?: () => Promise<void>;
|
||||||
|
preAction: PreAction;
|
||||||
onAction: OnAction;
|
onAction: OnAction;
|
||||||
onRunJob: (name: AssetJobName) => void;
|
onRunJob: (name: AssetJobName) => void;
|
||||||
onPlaySlideshow: () => void;
|
onPlaySlideshow: () => void;
|
||||||
@ -76,6 +77,7 @@
|
|||||||
showSlideshow = false,
|
showSlideshow = false,
|
||||||
onZoomImage,
|
onZoomImage,
|
||||||
onCopyImage,
|
onCopyImage,
|
||||||
|
preAction,
|
||||||
onAction,
|
onAction,
|
||||||
onRunJob,
|
onRunJob,
|
||||||
onPlaySlideshow,
|
onPlaySlideshow,
|
||||||
@ -149,7 +151,7 @@
|
|||||||
{/if} -->
|
{/if} -->
|
||||||
|
|
||||||
{#if isOwner}
|
{#if isOwner}
|
||||||
<DeleteAction {asset} {onAction} />
|
<DeleteAction {asset} {onAction} {preAction} />
|
||||||
|
|
||||||
<ButtonContextMenu direction="left" align="top-right" color="opaque" title={$t('more')} icon={mdiDotsVertical}>
|
<ButtonContextMenu direction="left" align="top-right" color="opaque" title={$t('more')} icon={mdiDotsVertical}>
|
||||||
{#if showSlideshow}
|
{#if showSlideshow}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { focusTrap } from '$lib/actions/focus-trap';
|
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 MotionPhotoAction from '$lib/components/asset-viewer/actions/motion-photo-action.svelte';
|
||||||
import NextAssetAction from '$lib/components/asset-viewer/actions/next-asset-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';
|
import PreviousAssetAction from '$lib/components/asset-viewer/actions/previous-asset-action.svelte';
|
||||||
@ -58,6 +58,7 @@
|
|||||||
isShared?: boolean;
|
isShared?: boolean;
|
||||||
album?: AlbumResponseDto | null;
|
album?: AlbumResponseDto | null;
|
||||||
person?: PersonResponseDto | null;
|
person?: PersonResponseDto | null;
|
||||||
|
preAction?: PreAction | undefined;
|
||||||
onAction?: OnAction | undefined;
|
onAction?: OnAction | undefined;
|
||||||
reactions?: ActivityResponseDto[];
|
reactions?: ActivityResponseDto[];
|
||||||
onClose: (dto: { asset: AssetResponseDto }) => void;
|
onClose: (dto: { asset: AssetResponseDto }) => void;
|
||||||
@ -75,6 +76,7 @@
|
|||||||
isShared = false,
|
isShared = false,
|
||||||
album = null,
|
album = null,
|
||||||
person = null,
|
person = null,
|
||||||
|
preAction = undefined,
|
||||||
onAction = undefined,
|
onAction = undefined,
|
||||||
reactions = $bindable([]),
|
reactions = $bindable([]),
|
||||||
onClose,
|
onClose,
|
||||||
@ -366,7 +368,9 @@
|
|||||||
const handleStackedAssetMouseEvent = (isMouseOver: boolean, asset: AssetResponseDto) => {
|
const handleStackedAssetMouseEvent = (isMouseOver: boolean, asset: AssetResponseDto) => {
|
||||||
previewStackedAsset = isMouseOver ? asset : undefined;
|
previewStackedAsset = isMouseOver ? asset : undefined;
|
||||||
};
|
};
|
||||||
|
const handlePreAction = (action: Action) => {
|
||||||
|
preAction?.(action);
|
||||||
|
};
|
||||||
const handleAction = async (action: Action) => {
|
const handleAction = async (action: Action) => {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case AssetAction.ADD_TO_ALBUM: {
|
case AssetAction.ADD_TO_ALBUM: {
|
||||||
@ -431,6 +435,7 @@
|
|||||||
showSlideshow={true}
|
showSlideshow={true}
|
||||||
onZoomImage={zoomToggle}
|
onZoomImage={zoomToggle}
|
||||||
onCopyImage={copyImage}
|
onCopyImage={copyImage}
|
||||||
|
preAction={handlePreAction}
|
||||||
onAction={handleAction}
|
onAction={handleAction}
|
||||||
onRunJob={handleRunJob}
|
onRunJob={handleRunJob}
|
||||||
onPlaySlideshow={() => ($slideshowState = SlideshowState.PlaySlideshow)}
|
onPlaySlideshow={() => ($slideshowState = SlideshowState.PlaySlideshow)}
|
||||||
|
@ -517,7 +517,6 @@
|
|||||||
|
|
||||||
const handleNext = async () => {
|
const handleNext = async () => {
|
||||||
const nextAsset = await $assetStore.getNextAsset($viewingAsset);
|
const nextAsset = await $assetStore.getNextAsset($viewingAsset);
|
||||||
|
|
||||||
if (nextAsset) {
|
if (nextAsset) {
|
||||||
const preloadAsset = await $assetStore.getNextAsset(nextAsset);
|
const preloadAsset = await $assetStore.getNextAsset(nextAsset);
|
||||||
assetViewingStore.setAsset(nextAsset, preloadAsset ? [preloadAsset] : []);
|
assetViewingStore.setAsset(nextAsset, preloadAsset ? [preloadAsset] : []);
|
||||||
@ -546,7 +545,7 @@
|
|||||||
await navigate({ targetRoute: 'current', assetId: null, assetGridRouteSearchParams: $gridScrollTarget });
|
await navigate({ targetRoute: 'current', assetId: null, assetGridRouteSearchParams: $gridScrollTarget });
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleAction = async (action: Action) => {
|
const handlePreAction = async (action: Action) => {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case removeAction:
|
case removeAction:
|
||||||
case AssetAction.TRASH:
|
case AssetAction.TRASH:
|
||||||
@ -560,7 +559,10 @@
|
|||||||
assetStore.removeAssets([action.asset.id]);
|
assetStore.removeAssets([action.asset.id]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const handleAction = (action: Action) => {
|
||||||
|
switch (action.type) {
|
||||||
case AssetAction.ARCHIVE:
|
case AssetAction.ARCHIVE:
|
||||||
case AssetAction.UNARCHIVE:
|
case AssetAction.UNARCHIVE:
|
||||||
case AssetAction.FAVORITE:
|
case AssetAction.FAVORITE:
|
||||||
@ -928,6 +930,7 @@
|
|||||||
{isShared}
|
{isShared}
|
||||||
{album}
|
{album}
|
||||||
{person}
|
{person}
|
||||||
|
preAction={handlePreAction}
|
||||||
onAction={handleAction}
|
onAction={handleAction}
|
||||||
onPrevious={handlePrevious}
|
onPrevious={handlePrevious}
|
||||||
onNext={handleNext}
|
onNext={handleNext}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user