mirror of
https://github.com/immich-app/immich.git
synced 2026-02-28 01:29:04 +03:00
fix(web): escape handling on album page (#26419)
This commit is contained in:
@@ -3,7 +3,6 @@
|
|||||||
import HeaderActionButton from '$lib/components/HeaderActionButton.svelte';
|
import HeaderActionButton from '$lib/components/HeaderActionButton.svelte';
|
||||||
import OnEvents from '$lib/components/OnEvents.svelte';
|
import OnEvents from '$lib/components/OnEvents.svelte';
|
||||||
import UserAvatar from '$lib/components/shared-components/user-avatar.svelte';
|
import UserAvatar from '$lib/components/shared-components/user-avatar.svelte';
|
||||||
import { AlbumPageViewMode } from '$lib/constants';
|
|
||||||
import {
|
import {
|
||||||
getAlbumActions,
|
getAlbumActions,
|
||||||
handleRemoveUserFromAlbum,
|
handleRemoveUserFromAlbum,
|
||||||
@@ -56,7 +55,7 @@
|
|||||||
sharedLinks = sharedLinks.filter(({ id }) => sharedLink.id !== id);
|
sharedLinks = sharedLinks.filter(({ id }) => sharedLink.id !== id);
|
||||||
};
|
};
|
||||||
|
|
||||||
const { AddUsers, CreateSharedLink } = $derived(getAlbumActions($t, album, AlbumPageViewMode.OPTIONS));
|
const { AddUsers, CreateSharedLink } = $derived(getAlbumActions($t, album));
|
||||||
|
|
||||||
let sharedLinks: SharedLinkResponseDto[] = $state([]);
|
let sharedLinks: SharedLinkResponseDto[] = $state([]);
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { goto } from '$app/navigation';
|
import { goto } from '$app/navigation';
|
||||||
import ToastAction from '$lib/components/ToastAction.svelte';
|
import ToastAction from '$lib/components/ToastAction.svelte';
|
||||||
import { AlbumPageViewMode } from '$lib/constants';
|
|
||||||
import { authManager } from '$lib/managers/auth-manager.svelte';
|
import { authManager } from '$lib/managers/auth-manager.svelte';
|
||||||
import { eventManager } from '$lib/managers/event-manager.svelte';
|
import { eventManager } from '$lib/managers/event-manager.svelte';
|
||||||
import type { TimelineAsset } from '$lib/managers/timeline-manager/types';
|
import type { TimelineAsset } from '$lib/managers/timeline-manager/types';
|
||||||
@@ -32,7 +31,7 @@ import {
|
|||||||
type UserResponseDto,
|
type UserResponseDto,
|
||||||
} from '@immich/sdk';
|
} from '@immich/sdk';
|
||||||
import { modalManager, toastManager, type ActionItem } from '@immich/ui';
|
import { modalManager, toastManager, type ActionItem } from '@immich/ui';
|
||||||
import { mdiArrowLeft, mdiLink, mdiPlus, mdiPlusBoxOutline, mdiShareVariantOutline, mdiUpload } from '@mdi/js';
|
import { mdiLink, mdiPlus, mdiPlusBoxOutline, mdiShareVariantOutline, mdiUpload } from '@mdi/js';
|
||||||
import { type MessageFormatter } from 'svelte-i18n';
|
import { type MessageFormatter } from 'svelte-i18n';
|
||||||
import { get } from 'svelte/store';
|
import { get } from 'svelte/store';
|
||||||
|
|
||||||
@@ -46,7 +45,7 @@ export const getAlbumsActions = ($t: MessageFormatter) => {
|
|||||||
return { Create };
|
return { Create };
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getAlbumActions = ($t: MessageFormatter, album: AlbumResponseDto, viewMode: AlbumPageViewMode) => {
|
export const getAlbumActions = ($t: MessageFormatter, album: AlbumResponseDto) => {
|
||||||
const isOwned = get(user).id === album.ownerId;
|
const isOwned = get(user).id === album.ownerId;
|
||||||
|
|
||||||
const Share: ActionItem = {
|
const Share: ActionItem = {
|
||||||
@@ -73,16 +72,7 @@ export const getAlbumActions = ($t: MessageFormatter, album: AlbumResponseDto, v
|
|||||||
onAction: () => modalManager.show(SharedLinkCreateModal, { albumId: album.id }),
|
onAction: () => modalManager.show(SharedLinkCreateModal, { albumId: album.id }),
|
||||||
};
|
};
|
||||||
|
|
||||||
const Close: ActionItem = {
|
return { Share, AddUsers, CreateSharedLink };
|
||||||
title: $t('go_back'),
|
|
||||||
type: $t('command'),
|
|
||||||
icon: mdiArrowLeft,
|
|
||||||
onAction: () => goto(Route.albums()),
|
|
||||||
$if: () => viewMode === AlbumPageViewMode.VIEW,
|
|
||||||
shortcuts: { key: 'Escape' },
|
|
||||||
};
|
|
||||||
|
|
||||||
return { Share, AddUsers, CreateSharedLink, Close };
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getAlbumAssetsActions = ($t: MessageFormatter, album: AlbumResponseDto, assets: TimelineAsset[]) => {
|
export const getAlbumAssetsActions = ($t: MessageFormatter, album: AlbumResponseDto, assets: TimelineAsset[]) => {
|
||||||
|
|||||||
@@ -127,10 +127,6 @@
|
|||||||
await handleCloseSelectAssets();
|
await handleCloseSelectAssets();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (viewMode === AlbumPageViewMode.OPTIONS) {
|
|
||||||
viewMode = AlbumPageViewMode.VIEW;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if ($showAssetViewer) {
|
if ($showAssetViewer) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -138,7 +134,7 @@
|
|||||||
cancelMultiselect(assetInteraction);
|
cancelMultiselect(assetInteraction);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return;
|
await goto(Route.albums());
|
||||||
};
|
};
|
||||||
|
|
||||||
const refreshAlbum = async () => {
|
const refreshAlbum = async () => {
|
||||||
@@ -311,8 +307,17 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
const { Cast } = $derived(getGlobalActions($t));
|
const { Cast } = $derived(getGlobalActions($t));
|
||||||
const { Share, Close } = $derived(getAlbumActions($t, album, viewMode));
|
const { Share } = $derived(getAlbumActions($t, album));
|
||||||
const { AddAssets, Upload } = $derived(getAlbumAssetsActions($t, album, timelineInteraction.selectedAssets));
|
const { AddAssets, Upload } = $derived(getAlbumAssetsActions($t, album, timelineInteraction.selectedAssets));
|
||||||
|
|
||||||
|
const Close = $derived({
|
||||||
|
title: $t('go_back'),
|
||||||
|
type: $t('command'),
|
||||||
|
icon: mdiArrowLeft,
|
||||||
|
onAction: handleEscape,
|
||||||
|
$if: () => !$showAssetViewer,
|
||||||
|
shortcuts: { key: 'Escape' },
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<OnEvents
|
<OnEvents
|
||||||
|
|||||||
Reference in New Issue
Block a user