mirror of
https://github.com/immich-app/immich
synced 2025-06-07 16:03:34 +00:00

* Refactor main index page * Refactor admin page * Refactor Auth endpoint * Refactor directory to prep for monorepo * Fixed refactoring path * Resolved file path in vite * Refactor photo index page * Refactor thumbnail * Fixed test * Refactor Video Viewer component * Refactor download file * Refactor navigation bar * Refactor upload file check * Simplify Upload Asset signature * PR feedback
56 lines
1.3 KiB
Svelte
56 lines
1.3 KiB
Svelte
<script lang="ts">
|
|
import { session } from '$app/stores';
|
|
import { fade } from 'svelte/transition';
|
|
|
|
import { createEventDispatcher, onMount } from 'svelte';
|
|
import LoadingSpinner from '../shared/loading-spinner.svelte';
|
|
import { api, AssetResponseDto } from '@api';
|
|
|
|
export let assetId: string;
|
|
export let deviceId: string;
|
|
|
|
let assetInfo: AssetResponseDto;
|
|
|
|
const dispatch = createEventDispatcher();
|
|
|
|
onMount(async () => {
|
|
if ($session.user) {
|
|
const { data } = await api.assetApi.getAssetById(assetId);
|
|
assetInfo = data;
|
|
}
|
|
});
|
|
|
|
const loadAssetData = async () => {
|
|
if ($session.user) {
|
|
try {
|
|
const { data } = await api.assetApi.serveFile(assetInfo.deviceAssetId, deviceId, false, true, {
|
|
responseType: 'blob',
|
|
});
|
|
|
|
if (!(data instanceof Blob)) {
|
|
return;
|
|
}
|
|
|
|
const assetData = URL.createObjectURL(data);
|
|
return assetData;
|
|
} catch (e) {}
|
|
}
|
|
};
|
|
</script>
|
|
|
|
<div transition:fade={{ duration: 150 }} class="flex place-items-center place-content-center h-full select-none">
|
|
{#if assetInfo}
|
|
{#await loadAssetData()}
|
|
<LoadingSpinner />
|
|
{:then assetData}
|
|
<img
|
|
transition:fade={{ duration: 150 }}
|
|
src={assetData}
|
|
alt={assetId}
|
|
class="object-contain h-full transition-all"
|
|
loading="lazy"
|
|
/>
|
|
{/await}
|
|
{/if}
|
|
</div>
|