2023-07-28 06:29:09 +02:00
|
|
|
<script lang="ts">
|
2024-02-14 06:38:57 -08:00
|
|
|
import { api } from '$lib/api';
|
|
|
|
|
import { getKey } from '$lib/utils';
|
|
|
|
|
import { type AssetResponseDto } from '@immich/sdk';
|
2023-07-28 06:29:09 +02:00
|
|
|
import { fade } from 'svelte/transition';
|
|
|
|
|
import LoadingSpinner from '../shared-components/loading-spinner.svelte';
|
2023-08-25 00:03:28 -04:00
|
|
|
|
2023-07-28 06:29:09 +02:00
|
|
|
export let asset: AssetResponseDto;
|
2023-08-25 00:03:28 -04:00
|
|
|
|
2023-07-28 06:29:09 +02:00
|
|
|
const loadAssetData = async () => {
|
2024-02-12 12:31:20 -08:00
|
|
|
const { data } = await api.assetApi.serveFile(
|
2024-02-14 08:09:49 -05:00
|
|
|
{ id: asset.id, isThumb: false, isWeb: false, key: getKey() },
|
2024-02-12 12:31:20 -08:00
|
|
|
{ responseType: 'blob' },
|
|
|
|
|
);
|
|
|
|
|
if (data instanceof Blob) {
|
|
|
|
|
return URL.createObjectURL(data);
|
|
|
|
|
} else {
|
|
|
|
|
throw new TypeError('Invalid data format');
|
2023-07-28 06:29:09 +02:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<div transition:fade={{ duration: 150 }} class="flex h-full select-none place-content-center place-items-center">
|
2024-02-12 12:31:20 -08:00
|
|
|
<!-- the photo sphere viewer is quite large, so lazy load it in parallel with loading the data -->
|
|
|
|
|
{#await Promise.all([loadAssetData(), import('./photo-sphere-viewer-adapter.svelte')])}
|
2023-07-28 06:29:09 +02:00
|
|
|
<LoadingSpinner />
|
2024-02-12 12:31:20 -08:00
|
|
|
{:then [data, module]}
|
|
|
|
|
<svelte:component this={module.default} panorama={data} />
|
|
|
|
|
{:catch}
|
|
|
|
|
Failed to load asset
|
2023-07-28 06:29:09 +02:00
|
|
|
{/await}
|
|
|
|
|
</div>
|