Add error for unsupported files

This commit is contained in:
JovannMC 2025-01-10 21:46:49 +03:00
parent d0b9d36894
commit 8e1f348d01
No known key found for this signature in database
3 changed files with 53 additions and 36 deletions

View File

@ -90,6 +90,7 @@ class Files {
); );
if (!converter) { if (!converter) {
log(["files"], `no converter found for ${file.name}`); log(["files"], `no converter found for ${file.name}`);
this.files.push(new VertFile(file, format, null));
return; return;
} }
const to = converter.supportedFormats.find((f) => f !== format); const to = converter.supportedFormats.find((f) => f !== format);

View File

@ -25,7 +25,7 @@ export class VertFile {
constructor( constructor(
public readonly file: File, public readonly file: File,
to: string, to: string,
converter?: Converter, converter?: Converter | null,
blobUrl?: string, blobUrl?: string,
) { ) {
this.to = to; this.to = to;

View File

@ -11,6 +11,7 @@
import { import {
Disc2Icon, Disc2Icon,
DownloadIcon, DownloadIcon,
FileQuestionIcon,
ImageIcon, ImageIcon,
RotateCwIcon, RotateCwIcon,
XIcon, XIcon,
@ -22,7 +23,9 @@
{@const isAudio = file.converter?.name === "ffmpeg" || false} {@const isAudio = file.converter?.name === "ffmpeg" || false}
<Panel class="p-5 flex flex-col min-w-0 gap-4 relative"> <Panel class="p-5 flex flex-col min-w-0 gap-4 relative">
<div class="flex-shrink-0 h-8 w-full flex items-center gap-2"> <div class="flex-shrink-0 h-8 w-full flex items-center gap-2">
{#if isAudio} {#if !file.converter}
<FileQuestionIcon size="24" class="flex-shrink-0" />
{:else if isAudio}
<Disc2Icon size="24" class="flex-shrink-0" /> <Disc2Icon size="24" class="flex-shrink-0" />
{:else} {:else}
<ImageIcon size="24" class="flex-shrink-0" /> <ImageIcon size="24" class="flex-shrink-0" />
@ -52,8 +55,20 @@
<XIcon size="24" class="text-muted" /> <XIcon size="24" class="text-muted" />
</button> </button>
</div> </div>
{#if !file.converter}
<div
class="h-full flex flex-col text-center justify-center text-red-600"
>
<p class="font-body font-bold">We can't convert this file.</p>
<p class="font-normal">
Only image and audio files are supported
</p>
</div>
{:else}
<div class="flex flex-row justify-between"> <div class="flex flex-row justify-between">
<div class="flex gap-4 w-full h-[152px] overflow-hidden relative"> <div
class="flex gap-4 w-full h-[152px] overflow-hidden relative"
>
<div class="w-1/2 h-full overflow-hidden rounded-xl"> <div class="w-1/2 h-full overflow-hidden rounded-xl">
<img <img
class="object-cover w-full h-full" class="object-cover w-full h-full"
@ -92,6 +107,7 @@
</div> </div>
</div> </div>
</div> </div>
{/if}
</Panel> </Panel>
{/snippet} {/snippet}
@ -113,7 +129,7 @@
<div <div
class="fixed w-screen h-screen opacity-75 overflow-hidden top-0 left-0 -z-50 pointer-events-none grid grid-cols-1 grid-rows-1" class="fixed w-screen h-screen opacity-75 overflow-hidden top-0 left-0 -z-50 pointer-events-none grid grid-cols-1 grid-rows-1"
> >
{#if files.files.length === 1} {#if files.files.length === 1 && files.files[0].blobUrl}
<div <div
class="w-full relative" class="w-full relative"
transition:fade={{ transition:fade={{