From e1c520b9e7a1a4bc396d9e1b20a12318ecacae9c Mon Sep 17 00:00:00 2001
From: Michel Heusschen <59014050+michelheusschen@users.noreply.github.com>
Date: Wed, 15 Feb 2023 18:56:19 +0100
Subject: [PATCH] feat(web): remove duplicate asset calls (#1764)
* feat(web): remove duplicate asset calls
* use source element instead of video.src
---
.../asset-viewer/asset-viewer.svelte | 2 +-
.../asset-viewer/photo-viewer.svelte | 37 ++++--------
.../asset-viewer/video-viewer.svelte | 59 ++++++-------------
3 files changed, 31 insertions(+), 67 deletions(-)
diff --git a/web/src/lib/components/asset-viewer/asset-viewer.svelte b/web/src/lib/components/asset-viewer/asset-viewer.svelte
index 2199359432..0703abfe11 100644
--- a/web/src/lib/components/asset-viewer/asset-viewer.svelte
+++ b/web/src/lib/components/asset-viewer/asset-viewer.svelte
@@ -304,7 +304,7 @@
on:onVideoEnded={() => (shouldPlayMotionPhoto = false)}
/>
{:else}
-
+
{/if}
{:else}
diff --git a/web/src/lib/components/asset-viewer/photo-viewer.svelte b/web/src/lib/components/asset-viewer/photo-viewer.svelte
index 9a2d2dacf2..13035047e7 100644
--- a/web/src/lib/components/asset-viewer/photo-viewer.svelte
+++ b/web/src/lib/components/asset-viewer/photo-viewer.svelte
@@ -10,22 +10,14 @@
NotificationType
} from '../shared-components/notification/notification';
- export let assetId: string;
+ export let asset: AssetResponseDto;
export let publicSharedKey = '';
- let assetInfo: AssetResponseDto;
let assetData: string;
let copyImageToClipboard: (src: string) => Promise;
onMount(async () => {
- const { data } = await api.assetApi.getAssetById(assetId, {
- params: {
- key: publicSharedKey
- }
- });
- assetInfo = data;
-
//Import hack :( see https://github.com/vadimkorr/svelte-carousel/issues/27#issuecomment-851022295
const module = await import('copy-image-clipboard');
copyImageToClipboard = module.copyImageToClipboard;
@@ -33,7 +25,7 @@
const loadAssetData = async () => {
try {
- const { data } = await api.assetApi.serveFile(assetInfo.id, false, true, {
+ const { data } = await api.assetApi.serveFile(asset.id, false, true, {
params: {
key: publicSharedKey
},
@@ -75,18 +67,15 @@
transition:fade={{ duration: 150 }}
class="flex place-items-center place-content-center h-full select-none"
>
- {#if assetInfo}
- {#await loadAssetData()}
-
- {:then assetData}
-
- {/await}
- {/if}
+ {#await loadAssetData()}
+
+ {:then assetData}
+
+ {/await}
diff --git a/web/src/lib/components/asset-viewer/video-viewer.svelte b/web/src/lib/components/asset-viewer/video-viewer.svelte
index ba1e580b00..dff3c44ff1 100644
--- a/web/src/lib/components/asset-viewer/video-viewer.svelte
+++ b/web/src/lib/components/asset-viewer/video-viewer.svelte
@@ -1,40 +1,17 @@