mirror of
https://github.com/immich-app/immich.git
synced 2026-01-09 07:41:22 +08:00
refactor: use eventManager
This commit is contained in:
parent
52578fe650
commit
e6346852f8
@ -54,8 +54,6 @@
|
|||||||
isShowDeleteConfirmation?: boolean;
|
isShowDeleteConfirmation?: boolean;
|
||||||
onSelect?: (asset: TimelineAsset) => void;
|
onSelect?: (asset: TimelineAsset) => void;
|
||||||
onEscape?: () => void;
|
onEscape?: () => void;
|
||||||
onKeyboardDelete?: (assetIds: string[]) => void;
|
|
||||||
onKeyboardArchive?: (ids: string[]) => void;
|
|
||||||
children?: Snippet;
|
children?: Snippet;
|
||||||
empty?: Snippet;
|
empty?: Snippet;
|
||||||
customThumbnailLayout?: Snippet<[TimelineAsset]>;
|
customThumbnailLayout?: Snippet<[TimelineAsset]>;
|
||||||
@ -89,8 +87,6 @@
|
|||||||
isShowDeleteConfirmation = $bindable(false),
|
isShowDeleteConfirmation = $bindable(false),
|
||||||
onSelect = () => {},
|
onSelect = () => {},
|
||||||
onEscape = () => {},
|
onEscape = () => {},
|
||||||
onKeyboardDelete,
|
|
||||||
onKeyboardArchive,
|
|
||||||
children,
|
children,
|
||||||
empty,
|
empty,
|
||||||
customThumbnailLayout,
|
customThumbnailLayout,
|
||||||
@ -608,8 +604,6 @@
|
|||||||
{assetInteraction}
|
{assetInteraction}
|
||||||
bind:isShowDeleteConfirmation
|
bind:isShowDeleteConfirmation
|
||||||
{onEscape}
|
{onEscape}
|
||||||
onAssetDelete={onKeyboardDelete}
|
|
||||||
onArchive={onKeyboardArchive}
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{#if timelineManager.months.length > 0}
|
{#if timelineManager.months.length > 0}
|
||||||
|
|||||||
@ -7,6 +7,7 @@
|
|||||||
setFocusTo as setFocusToInit,
|
setFocusTo as setFocusToInit,
|
||||||
} from '$lib/components/timeline/actions/focus-actions';
|
} from '$lib/components/timeline/actions/focus-actions';
|
||||||
import { AppRoute } from '$lib/constants';
|
import { AppRoute } from '$lib/constants';
|
||||||
|
import { eventManager } from '$lib/managers/event-manager.svelte';
|
||||||
import { featureFlagsManager } from '$lib/managers/feature-flags-manager.svelte';
|
import { featureFlagsManager } from '$lib/managers/feature-flags-manager.svelte';
|
||||||
import { TimelineManager } from '$lib/managers/timeline-manager/timeline-manager.svelte';
|
import { TimelineManager } from '$lib/managers/timeline-manager/timeline-manager.svelte';
|
||||||
import type { TimelineAsset } from '$lib/managers/timeline-manager/types';
|
import type { TimelineAsset } from '$lib/managers/timeline-manager/types';
|
||||||
@ -27,8 +28,6 @@
|
|||||||
assetInteraction: AssetInteraction;
|
assetInteraction: AssetInteraction;
|
||||||
isShowDeleteConfirmation: boolean;
|
isShowDeleteConfirmation: boolean;
|
||||||
onEscape?: () => void;
|
onEscape?: () => void;
|
||||||
onAssetDelete?: (assetIds: string[]) => void;
|
|
||||||
onArchive?: (ids: string[]) => void;
|
|
||||||
scrollToAsset: (asset: TimelineAsset) => boolean;
|
scrollToAsset: (asset: TimelineAsset) => boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,8 +36,6 @@
|
|||||||
assetInteraction,
|
assetInteraction,
|
||||||
isShowDeleteConfirmation = $bindable(false),
|
isShowDeleteConfirmation = $bindable(false),
|
||||||
onEscape,
|
onEscape,
|
||||||
onAssetDelete,
|
|
||||||
onArchive,
|
|
||||||
scrollToAsset,
|
scrollToAsset,
|
||||||
}: Props = $props();
|
}: Props = $props();
|
||||||
|
|
||||||
@ -50,7 +47,7 @@
|
|||||||
!(isTrashEnabled && !force),
|
!(isTrashEnabled && !force),
|
||||||
(assetIds) => {
|
(assetIds) => {
|
||||||
timelineManager.removeAssets(assetIds);
|
timelineManager.removeAssets(assetIds);
|
||||||
onAssetDelete?.(assetIds);
|
eventManager.emit('AssetsDelete', assetIds);
|
||||||
},
|
},
|
||||||
assetInteraction.selectedAssets,
|
assetInteraction.selectedAssets,
|
||||||
!isTrashEnabled || force ? undefined : (assets) => timelineManager.upsertAssets(assets),
|
!isTrashEnabled || force ? undefined : (assets) => timelineManager.upsertAssets(assets),
|
||||||
@ -88,7 +85,7 @@
|
|||||||
const visibility = assetInteraction.isAllArchived ? AssetVisibility.Timeline : AssetVisibility.Archive;
|
const visibility = assetInteraction.isAllArchived ? AssetVisibility.Timeline : AssetVisibility.Archive;
|
||||||
const ids = await archiveAssets(assetInteraction.selectedAssets, visibility);
|
const ids = await archiveAssets(assetInteraction.selectedAssets, visibility);
|
||||||
timelineManager.update(ids, (asset) => (asset.visibility = visibility));
|
timelineManager.update(ids, (asset) => (asset.visibility = visibility));
|
||||||
onArchive?.(ids);
|
eventManager.emit('AssetsArchive', ids);
|
||||||
deselectAllAssets();
|
deselectAllAssets();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -19,6 +19,8 @@ export type Events = {
|
|||||||
ThemeChange: [ThemeSetting];
|
ThemeChange: [ThemeSetting];
|
||||||
|
|
||||||
AssetReplace: [{ oldAssetId: string; newAssetId: string }];
|
AssetReplace: [{ oldAssetId: string; newAssetId: string }];
|
||||||
|
AssetsArchive: [string[]];
|
||||||
|
AssetsDelete: [string[]];
|
||||||
|
|
||||||
AlbumDelete: [AlbumResponseDto];
|
AlbumDelete: [AlbumResponseDto];
|
||||||
|
|
||||||
|
|||||||
@ -56,6 +56,7 @@
|
|||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
import { t } from 'svelte-i18n';
|
import { t } from 'svelte-i18n';
|
||||||
import type { PageData } from './$types';
|
import type { PageData } from './$types';
|
||||||
|
import OnEvents from '$lib/components/OnEvents.svelte';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
data: PageData;
|
data: PageData;
|
||||||
@ -342,6 +343,8 @@
|
|||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<OnEvents onAssetsDelete={updateAssetCount} onAssetsArchive={updateAssetCount} />
|
||||||
|
|
||||||
<main
|
<main
|
||||||
class="relative z-0 h-dvh overflow-hidden px-2 md:px-6 md:pt-(--navbar-height-md) pt-(--navbar-height)"
|
class="relative z-0 h-dvh overflow-hidden px-2 md:px-6 md:pt-(--navbar-height-md) pt-(--navbar-height)"
|
||||||
use:scrollMemoryClearer={{
|
use:scrollMemoryClearer={{
|
||||||
@ -362,8 +365,6 @@
|
|||||||
singleSelect={viewMode === PersonPageViewMode.SELECT_PERSON}
|
singleSelect={viewMode === PersonPageViewMode.SELECT_PERSON}
|
||||||
onSelect={handleSelectFeaturePhoto}
|
onSelect={handleSelectFeaturePhoto}
|
||||||
onEscape={handleEscape}
|
onEscape={handleEscape}
|
||||||
onKeyboardDelete={() => updateAssetCount()}
|
|
||||||
onKeyboardArchive={() => updateAssetCount()}
|
|
||||||
>
|
>
|
||||||
{#if viewMode === PersonPageViewMode.VIEW_ASSETS}
|
{#if viewMode === PersonPageViewMode.VIEW_ASSETS}
|
||||||
<!-- Person information block -->
|
<!-- Person information block -->
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user