From ac6670ef1b59180e3cf17a0298dc93260cefdb69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Ml=C3=A1dek?= Date: Thu, 3 Feb 2022 16:39:54 +0100 Subject: [PATCH] [ui] refactor blobpreview, fix model previews --- .../src/components/display/BlobPreview.svelte | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/webui/src/components/display/BlobPreview.svelte b/webui/src/components/display/BlobPreview.svelte index 7a3cd13..0fa383e 100644 --- a/webui/src/components/display/BlobPreview.svelte +++ b/webui/src/components/display/BlobPreview.svelte @@ -8,26 +8,32 @@ $: ({ entity } = useEntity(address)); $: mimeType = String($entity?.get("FILE_MIME")); - $: handled = - Boolean(mimeType) && - ["audio", "video", "image", "model", "text", "application/pdf"].some( - (prefix) => mimeType.startsWith(prefix) - ); + + $: audio = mimeType.startsWith("audio"); + $: video = ["video", "application/x-matroska"].some((p) => + mimeType.startsWith(p) + ); + $: image = mimeType.startsWith("image"); + $: text = mimeType.startsWith("text"); + $: pdf = mimeType.startsWith("pdf"); + $: model = mimeType?.startsWith("model"); + + $: handled = audio || video || image || text || pdf || model; let imageLoaded = null; {#if handled}
- {#if mimeType?.startsWith("text")} + {#if text}
{/if} - {#if mimeType?.startsWith("audio")} + {#if audio}