|
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 |
| - import { authManager } from '$lib/managers/auth-manager.svelte'; |
16 | 15 | import type { MonthGroup } from '$lib/managers/timeline-manager/month-group.svelte';
|
17 | 16 | import { TimelineManager } from '$lib/managers/timeline-manager/timeline-manager.svelte';
|
18 | 17 | import type { TimelineAsset } from '$lib/managers/timeline-manager/types';
|
|
26 | 25 | import { searchStore } from '$lib/stores/search.svelte';
|
27 | 26 | import { featureFlags } from '$lib/stores/server-config.store';
|
28 | 27 | import { handlePromiseError } from '$lib/utils';
|
29 |
| - import { deleteAssets, updateStackedAssetInTimeline, updateUnstackedAssetInTimeline } from '$lib/utils/actions'; |
| 28 | + import { deleteAssets, updateStackedAssetInTimeline } from '$lib/utils/actions'; |
30 | 29 | import { archiveAssets, cancelMultiselect, selectAllAssets, stackAssets } from '$lib/utils/asset-utils';
|
31 | 30 | import { navigate } from '$lib/utils/navigation';
|
32 |
| - import { getTimes, toTimelineAsset, type ScrubberListener, type TimelineYearMonth } from '$lib/utils/timeline-util'; |
33 |
| - import { AssetVisibility, getAssetInfo, type AlbumResponseDto, type PersonResponseDto } from '@immich/sdk'; |
| 31 | + import { getTimes, type ScrubberListener, type TimelineYearMonth } from '$lib/utils/timeline-util'; |
| 32 | + import { AssetVisibility, type AlbumResponseDto, type PersonResponseDto } from '@immich/sdk'; |
34 | 33 | import { modalManager } from '@immich/ui';
|
35 | 34 | import { DateTime } from 'luxon';
|
36 | 35 | import { onMount, type Snippet } from 'svelte';
|
|
53 | 52 | | AssetAction.ARCHIVE
|
54 | 53 | | AssetAction.FAVORITE
|
55 | 54 | | AssetAction.UNFAVORITE
|
56 |
| - | AssetAction.SET_VISIBILITY_TIMELINE |
57 |
| - | null; |
| 55 | + | AssetAction.SET_VISIBILITY_TIMELINE; |
58 | 56 | withStacked?: boolean;
|
59 | 57 | showArchiveIcon?: boolean;
|
60 | 58 | isShared?: boolean;
|
|
73 | 71 | enableRouting,
|
74 | 72 | timelineManager = $bindable(),
|
75 | 73 | assetInteraction,
|
76 |
| - removeAction = null, |
| 74 | + removeAction, |
77 | 75 | withStacked = false,
|
78 | 76 | showArchiveIcon = false,
|
79 | 77 | isShared = false,
|
|
86 | 84 | empty,
|
87 | 85 | }: Props = $props();
|
88 | 86 |
|
89 |
| - let { isViewing: showAssetViewer, asset: viewingAsset, preloadAssets, gridScrollTarget, mutex } = assetViewingStore; |
| 87 | + let { isViewing: showAssetViewer, gridScrollTarget, mutex } = assetViewingStore; |
90 | 88 |
|
91 | 89 | let element: HTMLElement | undefined = $state();
|
92 | 90 |
|
|
448 | 446 | }
|
449 | 447 | };
|
450 | 448 |
|
451 |
| - const handlePrevious = async () => { |
452 |
| - const release = await mutex.acquire(); |
453 |
| - const laterAsset = await timelineManager.getLaterAsset($viewingAsset); |
454 |
| -
|
455 |
| - if (laterAsset) { |
456 |
| - const preloadAsset = await timelineManager.getLaterAsset(laterAsset); |
457 |
| - const asset = await getAssetInfo({ ...authManager.params, id: laterAsset.id }); |
458 |
| - assetViewingStore.setAsset(asset, preloadAsset ? [preloadAsset] : []); |
459 |
| - await navigate({ targetRoute: 'current', assetId: laterAsset.id }); |
460 |
| - } |
461 |
| -
|
462 |
| - release(); |
463 |
| - return !!laterAsset; |
464 |
| - }; |
465 |
| -
|
466 |
| - const handleNext = async () => { |
467 |
| - const release = await mutex.acquire(); |
468 |
| - const earlierAsset = await timelineManager.getEarlierAsset($viewingAsset); |
469 |
| -
|
470 |
| - if (earlierAsset) { |
471 |
| - const preloadAsset = await timelineManager.getEarlierAsset(earlierAsset); |
472 |
| - const asset = await getAssetInfo({ ...authManager.params, id: earlierAsset.id }); |
473 |
| - assetViewingStore.setAsset(asset, preloadAsset ? [preloadAsset] : []); |
474 |
| - await navigate({ targetRoute: 'current', assetId: earlierAsset.id }); |
475 |
| - } |
476 |
| -
|
477 |
| - release(); |
478 |
| - return !!earlierAsset; |
479 |
| - }; |
480 |
| -
|
481 |
| - const handleRandom = async () => { |
482 |
| - const randomAsset = await timelineManager.getRandomAsset(); |
483 |
| -
|
484 |
| - if (randomAsset) { |
485 |
| - const asset = await getAssetInfo({ ...authManager.params, id: randomAsset.id }); |
486 |
| - assetViewingStore.setAsset(asset); |
487 |
| - await navigate({ targetRoute: 'current', assetId: randomAsset.id }); |
488 |
| - return asset; |
489 |
| - } |
490 |
| - }; |
491 |
| -
|
492 |
| - const handleClose = async (asset: { id: string }) => { |
493 |
| - assetViewingStore.showAssetViewer(false); |
494 |
| - showSkeleton = true; |
495 |
| - $gridScrollTarget = { at: asset.id }; |
496 |
| - await navigate({ targetRoute: 'current', assetId: null, assetGridRouteSearchParams: $gridScrollTarget }); |
497 |
| - }; |
498 |
| -
|
499 |
| - const handlePreAction = async (action: Action) => { |
500 |
| - switch (action.type) { |
501 |
| - case removeAction: |
502 |
| - case AssetAction.TRASH: |
503 |
| - case AssetAction.RESTORE: |
504 |
| - case AssetAction.DELETE: |
505 |
| - case AssetAction.ARCHIVE: |
506 |
| - case AssetAction.SET_VISIBILITY_LOCKED: |
507 |
| - case AssetAction.SET_VISIBILITY_TIMELINE: { |
508 |
| - // find the next asset to show or close the viewer |
509 |
| - // eslint-disable-next-line @typescript-eslint/no-unused-expressions |
510 |
| - (await handleNext()) || (await handlePrevious()) || (await handleClose(action.asset)); |
511 |
| -
|
512 |
| - // delete after find the next one |
513 |
| - timelineManager.removeAssets([action.asset.id]); |
514 |
| - break; |
515 |
| - } |
516 |
| - } |
517 |
| - }; |
518 |
| - const handleAction = (action: Action) => { |
519 |
| - switch (action.type) { |
520 |
| - case AssetAction.ARCHIVE: |
521 |
| - case AssetAction.UNARCHIVE: |
522 |
| - case AssetAction.FAVORITE: |
523 |
| - case AssetAction.UNFAVORITE: { |
524 |
| - timelineManager.updateAssets([action.asset]); |
525 |
| - break; |
526 |
| - } |
527 |
| -
|
528 |
| - case AssetAction.ADD: { |
529 |
| - timelineManager.addAssets([action.asset]); |
530 |
| - break; |
531 |
| - } |
532 |
| -
|
533 |
| - case AssetAction.UNSTACK: { |
534 |
| - updateUnstackedAssetInTimeline(timelineManager, action.assets); |
535 |
| - break; |
536 |
| - } |
537 |
| - case AssetAction.REMOVE_ASSET_FROM_STACK: { |
538 |
| - timelineManager.addAssets([toTimelineAsset(action.asset)]); |
539 |
| - if (action.stack) { |
540 |
| - //Have to unstack then restack assets in timeline in order to update the stack count in the timeline. |
541 |
| - updateUnstackedAssetInTimeline( |
542 |
| - timelineManager, |
543 |
| - action.stack.assets.map((asset) => toTimelineAsset(asset)), |
544 |
| - ); |
545 |
| - updateStackedAssetInTimeline(timelineManager, { |
546 |
| - stack: action.stack, |
547 |
| - toDeleteIds: action.stack.assets |
548 |
| - .filter((asset) => asset.id !== action.stack?.primaryAssetId) |
549 |
| - .map((asset) => asset.id), |
550 |
| - }); |
551 |
| - } |
552 |
| - break; |
553 |
| - } |
554 |
| - case AssetAction.SET_STACK_PRIMARY_ASSET: { |
555 |
| - //Have to unstack then restack assets in timeline in order for the currently removed new primary asset to be made visible. |
556 |
| - updateUnstackedAssetInTimeline( |
557 |
| - timelineManager, |
558 |
| - action.stack.assets.map((asset) => toTimelineAsset(asset)), |
559 |
| - ); |
560 |
| - updateStackedAssetInTimeline(timelineManager, { |
561 |
| - stack: action.stack, |
562 |
| - toDeleteIds: action.stack.assets |
563 |
| - .filter((asset) => asset.id !== action.stack.primaryAssetId) |
564 |
| - .map((asset) => asset.id), |
565 |
| - }); |
566 |
| - break; |
567 |
| - } |
568 |
| - } |
569 |
| - }; |
570 |
| -
|
571 | 449 | let lastAssetMouseEvent: TimelineAsset | null = $state(null);
|
572 | 450 |
|
573 | 451 | let shiftKeyIsDown = $state(false);
|
|
955 | 833 | </section>
|
956 | 834 | </section>
|
957 | 835 |
|
958 |
| -<Portal target="body"> |
959 |
| - {#if $showAssetViewer} |
960 |
| - {#await import('../asset-viewer/asset-viewer.svelte') then { default: AssetViewer }} |
961 |
| - <AssetViewer |
| 836 | +{#if !albumMapViewManager.isInMapView} |
| 837 | + <Portal target="body"> |
| 838 | + {#if $showAssetViewer} |
| 839 | + <AssetViewerAndActions |
| 840 | + bind:showSkeleton |
| 841 | + {timelineManager} |
| 842 | + {removeAction} |
962 | 843 | {withStacked}
|
963 |
| - asset={$viewingAsset} |
964 |
| - preloadAssets={$preloadAssets} |
965 | 844 | {isShared}
|
966 | 845 | {album}
|
967 | 846 | {person}
|
968 |
| - preAction={handlePreAction} |
969 |
| - onAction={handleAction} |
970 |
| - onPrevious={handlePrevious} |
971 |
| - onNext={handleNext} |
972 |
| - onRandom={handleRandom} |
973 |
| - onClose={handleClose} |
974 |
| - /> |
975 |
| - {/await} |
976 |
| - {/if} |
977 |
| -</Portal> |
| 847 | + {isShowDeleteConfirmation} |
| 848 | + ></AssetViewerAndActions> |
| 849 | + {/if} |
| 850 | + </Portal> |
| 851 | +{/if} |
978 | 852 |
|
979 | 853 | <style>
|
980 | 854 | #asset-grid {
|
|
0 commit comments