|
1 | 1 | <script lang="ts">
|
2 | 2 | import { getAssetOriginalUrl, getKey } from '$lib/utils';
|
| 3 | + import { isWebCompatibleImage } from '$lib/utils/asset-utils'; |
3 | 4 | import { AssetMediaSize, AssetTypeEnum, viewAsset, type AssetResponseDto } from '@immich/sdk';
|
4 | 5 | import type { AdapterConstructor, PluginConstructor } from '@photo-sphere-viewer/core';
|
5 | 6 | import { fade } from 'svelte/transition';
|
6 | 7 | import LoadingSpinner from '../shared-components/loading-spinner.svelte';
|
7 | 8 | import { t } from 'svelte-i18n';
|
8 |
| - export let asset: Pick<AssetResponseDto, 'id' | 'type'>; |
| 9 | + export let asset: { id: string; type: AssetTypeEnum.Video } | AssetResponseDto; |
9 | 10 |
|
10 | 11 | const photoSphereConfigs =
|
11 | 12 | asset.type === AssetTypeEnum.Video
|
|
27 | 28 | const url = URL.createObjectURL(data);
|
28 | 29 | return url;
|
29 | 30 | };
|
| 31 | +
|
| 32 | + const originalImageUrl = |
| 33 | + asset.type === AssetTypeEnum.Image && isWebCompatibleImage(asset) ? getAssetOriginalUrl(asset.id) : null; |
30 | 34 | </script>
|
31 | 35 |
|
32 | 36 | <div transition:fade={{ duration: 150 }} class="flex h-full select-none place-content-center place-items-center">
|
33 | 37 | <!-- the photo sphere viewer is quite large, so lazy load it in parallel with loading the data -->
|
34 | 38 | {#await Promise.all([loadAssetData(), import('./photo-sphere-viewer-adapter.svelte'), ...photoSphereConfigs])}
|
35 | 39 | <LoadingSpinner />
|
36 | 40 | {:then [data, module, adapter, plugins, navbar]}
|
37 |
| - <svelte:component this={module.default} panorama={data} plugins={plugins ?? undefined} {navbar} {adapter} /> |
| 41 | + <svelte:component |
| 42 | + this={module.default} |
| 43 | + panorama={data} |
| 44 | + plugins={plugins ?? undefined} |
| 45 | + {navbar} |
| 46 | + {adapter} |
| 47 | + {originalImageUrl} |
| 48 | + /> |
38 | 49 | {:catch}
|
39 | 50 | {$t('errors.failed_to_load_asset')}
|
40 | 51 | {/await}
|
|
0 commit comments