|
3 | 3 | import { page } from '$app/stores';
|
4 | 4 | import { resizeObserver, type OnResizeCallback } from '$lib/actions/resize-observer';
|
5 | 5 | import { shortcuts, type ShortcutOptions } from '$lib/actions/shortcut';
|
6 |
| - import type { Action } from '$lib/components/asset-viewer/actions/action'; |
7 | 6 | import {
|
8 | 7 | setFocusToAsset as setFocusAssetInit,
|
9 | 8 | setFocusTo as setFocusToInit,
|
10 | 9 | } from '$lib/components/photos-page/actions/focus-actions';
|
| 10 | + import AssetViewerAndActions from '$lib/components/photos-page/asset-viewer-and-actions.svelte'; |
11 | 11 | import Skeleton from '$lib/components/photos-page/skeleton.svelte';
|
12 | 12 | import ChangeDate from '$lib/components/shared-components/change-date.svelte';
|
13 | 13 | import Scrubber from '$lib/components/shared-components/scrubber/scrubber.svelte';
|
14 | 14 | import { AppRoute, AssetAction } from '$lib/constants';
|
15 | 15 | import { albumMapViewManager } from '$lib/managers/album-view-map.manager.svelte';
|
16 |
| - import { authManager } from '$lib/managers/auth-manager.svelte'; |
17 | 16 | import { modalManager } from '$lib/managers/modal-manager.svelte';
|
18 | 17 | import type { MonthGroup } from '$lib/managers/timeline-manager/month-group.svelte';
|
19 | 18 | import { TimelineManager } from '$lib/managers/timeline-manager/timeline-manager.svelte';
|
|
28 | 27 | import { searchStore } from '$lib/stores/search.svelte';
|
29 | 28 | import { featureFlags } from '$lib/stores/server-config.store';
|
30 | 29 | import { handlePromiseError } from '$lib/utils';
|
31 |
| - import { deleteAssets, updateStackedAssetInTimeline, updateUnstackedAssetInTimeline } from '$lib/utils/actions'; |
| 30 | + import { deleteAssets, updateStackedAssetInTimeline } from '$lib/utils/actions'; |
32 | 31 | import { archiveAssets, cancelMultiselect, selectAllAssets, stackAssets } from '$lib/utils/asset-utils';
|
33 | 32 | import { navigate } from '$lib/utils/navigation';
|
34 |
| - import { toTimelineAsset, type ScrubberListener, type TimelinePlainYearMonth } from '$lib/utils/timeline-util'; |
35 |
| - import { AssetVisibility, getAssetInfo, type AlbumResponseDto, type PersonResponseDto } from '@immich/sdk'; |
| 33 | + import { type ScrubberListener, type TimelinePlainYearMonth } from '$lib/utils/timeline-util'; |
| 34 | + import { AssetVisibility, type AlbumResponseDto, type PersonResponseDto } from '@immich/sdk'; |
36 | 35 | import { DateTime } from 'luxon';
|
37 | 36 | import { onMount, type Snippet } from 'svelte';
|
38 | 37 | import type { UpdatePayload } from 'vite';
|
|
54 | 53 | | AssetAction.ARCHIVE
|
55 | 54 | | AssetAction.FAVORITE
|
56 | 55 | | AssetAction.UNFAVORITE
|
57 |
| - | AssetAction.SET_VISIBILITY_TIMELINE |
58 |
| - | null; |
| 56 | + | AssetAction.SET_VISIBILITY_TIMELINE; |
59 | 57 | withStacked?: boolean;
|
60 | 58 | showArchiveIcon?: boolean;
|
61 | 59 | isShared?: boolean;
|
|
74 | 72 | enableRouting,
|
75 | 73 | timelineManager = $bindable(),
|
76 | 74 | assetInteraction,
|
77 |
| - removeAction = null, |
| 75 | + removeAction, |
78 | 76 | withStacked = false,
|
79 | 77 | showArchiveIcon = false,
|
80 | 78 | isShared = false,
|
|
87 | 85 | empty,
|
88 | 86 | }: Props = $props();
|
89 | 87 |
|
90 |
| - let { isViewing: showAssetViewer, asset: viewingAsset, preloadAssets, gridScrollTarget } = assetViewingStore; |
| 88 | + let { isViewing: showAssetViewer, gridScrollTarget } = assetViewingStore; |
91 | 89 |
|
92 | 90 | let element: HTMLElement | undefined = $state();
|
93 | 91 |
|
|
433 | 431 | }
|
434 | 432 | };
|
435 | 433 |
|
436 |
| - const handlePrevious = async () => { |
437 |
| - const laterAsset = await timelineManager.getLaterAsset($viewingAsset); |
438 |
| -
|
439 |
| - if (laterAsset) { |
440 |
| - const preloadAsset = await timelineManager.getLaterAsset(laterAsset); |
441 |
| - const asset = await getAssetInfo({ id: laterAsset.id, key: authManager.key }); |
442 |
| - assetViewingStore.setAsset(asset, preloadAsset ? [preloadAsset] : []); |
443 |
| - await navigate({ targetRoute: 'current', assetId: laterAsset.id }); |
444 |
| - } |
445 |
| -
|
446 |
| - return !!laterAsset; |
447 |
| - }; |
448 |
| -
|
449 |
| - const handleNext = async () => { |
450 |
| - const earlierAsset = await timelineManager.getEarlierAsset($viewingAsset); |
451 |
| - if (earlierAsset) { |
452 |
| - const preloadAsset = await timelineManager.getEarlierAsset(earlierAsset); |
453 |
| - const asset = await getAssetInfo({ id: earlierAsset.id, key: authManager.key }); |
454 |
| - assetViewingStore.setAsset(asset, preloadAsset ? [preloadAsset] : []); |
455 |
| - await navigate({ targetRoute: 'current', assetId: earlierAsset.id }); |
456 |
| - } |
457 |
| -
|
458 |
| - return !!earlierAsset; |
459 |
| - }; |
460 |
| -
|
461 |
| - const handleRandom = async () => { |
462 |
| - const randomAsset = await timelineManager.getRandomAsset(); |
463 |
| -
|
464 |
| - if (randomAsset) { |
465 |
| - const asset = await getAssetInfo({ id: randomAsset.id, key: authManager.key }); |
466 |
| - assetViewingStore.setAsset(asset); |
467 |
| - await navigate({ targetRoute: 'current', assetId: randomAsset.id }); |
468 |
| - return asset; |
469 |
| - } |
470 |
| - }; |
471 |
| -
|
472 |
| - const handleClose = async (asset: { id: string }) => { |
473 |
| - assetViewingStore.showAssetViewer(false); |
474 |
| - showSkeleton = true; |
475 |
| - $gridScrollTarget = { at: asset.id }; |
476 |
| - await navigate({ targetRoute: 'current', assetId: null, assetGridRouteSearchParams: $gridScrollTarget }); |
477 |
| - }; |
478 |
| -
|
479 |
| - const handlePreAction = async (action: Action) => { |
480 |
| - switch (action.type) { |
481 |
| - case removeAction: |
482 |
| - case AssetAction.TRASH: |
483 |
| - case AssetAction.RESTORE: |
484 |
| - case AssetAction.DELETE: |
485 |
| - case AssetAction.ARCHIVE: |
486 |
| - case AssetAction.SET_VISIBILITY_LOCKED: |
487 |
| - case AssetAction.SET_VISIBILITY_TIMELINE: { |
488 |
| - // find the next asset to show or close the viewer |
489 |
| - // eslint-disable-next-line @typescript-eslint/no-unused-expressions |
490 |
| - (await handleNext()) || (await handlePrevious()) || (await handleClose(action.asset)); |
491 |
| -
|
492 |
| - // delete after find the next one |
493 |
| - timelineManager.removeAssets([action.asset.id]); |
494 |
| - break; |
495 |
| - } |
496 |
| - } |
497 |
| - }; |
498 |
| - const handleAction = (action: Action) => { |
499 |
| - switch (action.type) { |
500 |
| - case AssetAction.ARCHIVE: |
501 |
| - case AssetAction.UNARCHIVE: |
502 |
| - case AssetAction.FAVORITE: |
503 |
| - case AssetAction.UNFAVORITE: { |
504 |
| - timelineManager.updateAssets([action.asset]); |
505 |
| - break; |
506 |
| - } |
507 |
| -
|
508 |
| - case AssetAction.ADD: { |
509 |
| - timelineManager.addAssets([action.asset]); |
510 |
| - break; |
511 |
| - } |
512 |
| -
|
513 |
| - case AssetAction.UNSTACK: { |
514 |
| - updateUnstackedAssetInTimeline(timelineManager, action.assets); |
515 |
| - break; |
516 |
| - } |
517 |
| - case AssetAction.SET_STACK_PRIMARY_ASSET: { |
518 |
| - //Have to unstack then restack assets in timeline in order for the currently removed new primary asset to be made visible. |
519 |
| - updateUnstackedAssetInTimeline( |
520 |
| - timelineManager, |
521 |
| - action.stack.assets.map((asset) => toTimelineAsset(asset)), |
522 |
| - ); |
523 |
| - updateStackedAssetInTimeline(timelineManager, { |
524 |
| - stack: action.stack, |
525 |
| - toDeleteIds: action.stack.assets |
526 |
| - .filter((asset) => asset.id !== action.stack.primaryAssetId) |
527 |
| - .map((asset) => asset.id), |
528 |
| - }); |
529 |
| - break; |
530 |
| - } |
531 |
| - } |
532 |
| - }; |
533 |
| -
|
534 | 434 | let lastAssetMouseEvent: TimelineAsset | null = $state(null);
|
535 | 435 |
|
536 | 436 | let shiftKeyIsDown = $state(false);
|
|
703 | 603 | }
|
704 | 604 |
|
705 | 605 | isShortcutModalOpen = true;
|
706 |
| - await modalManager.show(ShortcutsModal); |
| 606 | + await modalManager.show(ShortcutsModal, {}); |
707 | 607 | isShortcutModalOpen = false;
|
708 | 608 | };
|
709 | 609 |
|
|
914 | 814 | {#if !albumMapViewManager.isInMapView}
|
915 | 815 | <Portal target="body">
|
916 | 816 | {#if $showAssetViewer}
|
917 |
| - {#await import('../asset-viewer/asset-viewer.svelte') then { default: AssetViewer }} |
918 |
| - <AssetViewer |
919 |
| - {withStacked} |
920 |
| - asset={$viewingAsset} |
921 |
| - preloadAssets={$preloadAssets} |
922 |
| - {isShared} |
923 |
| - {album} |
924 |
| - {person} |
925 |
| - preAction={handlePreAction} |
926 |
| - onAction={handleAction} |
927 |
| - onPrevious={handlePrevious} |
928 |
| - onNext={handleNext} |
929 |
| - onRandom={handleRandom} |
930 |
| - onClose={handleClose} |
931 |
| - /> |
932 |
| - {/await} |
| 817 | + <AssetViewerAndActions |
| 818 | + bind:showSkeleton |
| 819 | + {timelineManager} |
| 820 | + {removeAction} |
| 821 | + {withStacked} |
| 822 | + {isShared} |
| 823 | + {album} |
| 824 | + {person} |
| 825 | + {isShowDeleteConfirmation} |
| 826 | + ></AssetViewerAndActions> |
933 | 827 | {/if}
|
934 | 828 | </Portal>
|
935 | 829 | {/if}
|
|
0 commit comments