|
1 | 1 | <script lang="ts">
|
2 | 2 | import { goto } from '$app/navigation';
|
3 |
| - import { AppRoute } from '$lib/constants'; |
| 3 | + import type { Action } from '$lib/components/asset-viewer/actions/action'; |
| 4 | + import { AppRoute, AssetAction } from '$lib/constants'; |
4 | 5 | import { dragAndDropFilesStore } from '$lib/stores/drag-and-drop-files.store';
|
5 | 6 | import { getKey, handlePromiseError } from '$lib/utils';
|
6 | 7 | import { downloadArchive } from '$lib/utils/asset-utils';
|
|
14 | 15 | import AssetSelectControlBar from '../photos-page/asset-select-control-bar.svelte';
|
15 | 16 | import ControlAppBar from '../shared-components/control-app-bar.svelte';
|
16 | 17 | import GalleryViewer from '../shared-components/gallery-viewer/gallery-viewer.svelte';
|
| 18 | + import AssetViewer from '../asset-viewer/asset-viewer.svelte'; |
17 | 19 | import { cancelMultiselect } from '$lib/utils/asset-utils';
|
18 | 20 | import ImmichLogoSmallLink from '$lib/components/shared-components/immich-logo-small-link.svelte';
|
19 | 21 | import { NotificationType, notificationController } from '../shared-components/notification/notification';
|
|
72 | 74 | const handleSelectAll = () => {
|
73 | 75 | assetInteraction.selectAssets(assets);
|
74 | 76 | };
|
| 77 | +
|
| 78 | + const handleAction = async (action: Action) => { |
| 79 | + switch (action.type) { |
| 80 | + case AssetAction.ARCHIVE: |
| 81 | + case AssetAction.DELETE: |
| 82 | + case AssetAction.TRASH: { |
| 83 | + await goto(AppRoute.PHOTOS); |
| 84 | + break; |
| 85 | + } |
| 86 | + } |
| 87 | + }; |
75 | 88 | </script>
|
76 | 89 |
|
77 | 90 | <section class="bg-immich-bg dark:bg-immich-dark-bg">
|
78 |
| - {#if assetInteraction.selectionActive} |
79 |
| - <AssetSelectControlBar |
80 |
| - assets={assetInteraction.selectedAssets} |
81 |
| - clearSelect={() => cancelMultiselect(assetInteraction)} |
82 |
| - > |
83 |
| - <CircleIconButton title={$t('select_all')} icon={mdiSelectAll} onclick={handleSelectAll} /> |
84 |
| - {#if sharedLink?.allowDownload} |
85 |
| - <DownloadAction filename="immich-shared.zip" /> |
86 |
| - {/if} |
87 |
| - {#if isOwned} |
88 |
| - <RemoveFromSharedLink bind:sharedLink /> |
89 |
| - {/if} |
90 |
| - </AssetSelectControlBar> |
91 |
| - {:else} |
92 |
| - <ControlAppBar onClose={() => goto(AppRoute.PHOTOS)} backIcon={mdiArrowLeft} showBackButton={false}> |
93 |
| - {#snippet leading()} |
94 |
| - <ImmichLogoSmallLink /> |
95 |
| - {/snippet} |
96 |
| - |
97 |
| - {#snippet trailing()} |
98 |
| - {#if sharedLink?.allowUpload} |
99 |
| - <CircleIconButton |
100 |
| - title={$t('add_photos')} |
101 |
| - onclick={() => handleUploadAssets()} |
102 |
| - icon={mdiFileImagePlusOutline} |
103 |
| - /> |
104 |
| - {/if} |
105 |
| - |
| 91 | + {#if sharedLink?.allowUpload} |
| 92 | + {#if assetInteraction.selectionActive} |
| 93 | + <AssetSelectControlBar |
| 94 | + assets={assetInteraction.selectedAssets} |
| 95 | + clearSelect={() => cancelMultiselect(assetInteraction)} |
| 96 | + > |
| 97 | + <CircleIconButton title={$t('select_all')} icon={mdiSelectAll} onclick={handleSelectAll} /> |
106 | 98 | {#if sharedLink?.allowDownload}
|
107 |
| - <CircleIconButton title={$t('download')} onclick={downloadAssets} icon={mdiFolderDownloadOutline} /> |
| 99 | + <DownloadAction filename="immich-shared.zip" /> |
| 100 | + {/if} |
| 101 | + {#if isOwned} |
| 102 | + <RemoveFromSharedLink bind:sharedLink /> |
108 | 103 | {/if}
|
109 |
| - {/snippet} |
110 |
| - </ControlAppBar> |
| 104 | + </AssetSelectControlBar> |
| 105 | + {:else} |
| 106 | + <ControlAppBar onClose={() => goto(AppRoute.PHOTOS)} backIcon={mdiArrowLeft} showBackButton={false}> |
| 107 | + {#snippet leading()} |
| 108 | + <ImmichLogoSmallLink /> |
| 109 | + {/snippet} |
| 110 | + |
| 111 | + {#snippet trailing()} |
| 112 | + {#if sharedLink?.allowUpload} |
| 113 | + <CircleIconButton |
| 114 | + title={$t('add_photos')} |
| 115 | + onclick={() => handleUploadAssets()} |
| 116 | + icon={mdiFileImagePlusOutline} |
| 117 | + /> |
| 118 | + {/if} |
| 119 | + |
| 120 | + {#if sharedLink?.allowDownload} |
| 121 | + <CircleIconButton title={$t('download')} onclick={downloadAssets} icon={mdiFolderDownloadOutline} /> |
| 122 | + {/if} |
| 123 | + {/snippet} |
| 124 | + </ControlAppBar> |
| 125 | + {/if} |
| 126 | + <section class="my-[160px] mx-4" bind:clientHeight={viewport.height} bind:clientWidth={viewport.width}> |
| 127 | + <GalleryViewer {assets} {assetInteraction} {viewport} /> |
| 128 | + </section> |
| 129 | + {:else} |
| 130 | + <AssetViewer |
| 131 | + asset={assets[0]} |
| 132 | + showCloseButton={false} |
| 133 | + onAction={handleAction} |
| 134 | + onPrevious={() => {}} |
| 135 | + onNext={() => {}} |
| 136 | + onRandom={() => {}} |
| 137 | + onClose={() => {}} |
| 138 | + /> |
111 | 139 | {/if}
|
112 |
| - <section class="my-[160px] mx-4" bind:clientHeight={viewport.height} bind:clientWidth={viewport.width}> |
113 |
| - <GalleryViewer {assets} {assetInteraction} {viewport} /> |
114 |
| - </section> |
115 | 140 | </section>
|
0 commit comments