[ui] show OG image in BlobPreview

feat/vaults
Tomáš Mládek 2022-02-10 11:43:31 +01:00
parent 423e039d0a
commit a1db8c2920
No known key found for this signature in database
GPG Key ID: ED21612889E75EC5
1 changed files with 14 additions and 2 deletions

View File

@ -5,7 +5,7 @@
import TextViewer from "./blobs/TextViewer.svelte";
export let address: string;
$: ({ entity } = useEntity(address));
$: ({ entity, entityInfo } = useEntity(address));
$: mimeType = String($entity?.get("FILE_MIME"));
@ -19,8 +19,9 @@
$: text = mimeType.startsWith("text");
$: pdf = mimeType.startsWith("application/pdf");
$: model = mimeType?.startsWith("model");
$: web = $entityInfo?.t == "Url";
$: handled = audio || video || image || text || pdf || model;
$: handled = audio || video || image || text || pdf || model || web;
let imageLoaded = null;
</script>
@ -86,6 +87,17 @@
{#if model}
<ModelViewer src="api/raw/{address}" />
{/if}
{#if web}
{#if imageLoaded != address}
<Spinner />
{/if}
<img
src={String($entity?.get("OG_IMAGE"))}
alt="OpenGraph image for {$entityInfo?.t == 'Url' && $entityInfo?.c}"
on:load={() => (imageLoaded = address)}
on:error={() => (handled = false)}
/>
{/if}
</div>
{/if}