fix: don't allow converting to same format

This commit is contained in:
JovannMC 2025-04-25 17:08:23 +03:00
parent f16a12f1c0
commit 95d57a0427
No known key found for this signature in database
2 changed files with 10 additions and 13 deletions

View File

@ -67,17 +67,16 @@
<div class="flex items-center gap-2"> <div class="flex items-center gap-2">
<p class="whitespace-nowrap text-xl">Set all to</p> <p class="whitespace-nowrap text-xl">Set all to</p>
{#if files.requiredConverters.length === 1} {#if files.requiredConverters.length === 1}
<!-- cannot convert to svg or heif --> {@const supported = files.files[0]?.converters.flatMap((c) =>
{@const supported = files.files[0]?.converters c.formatStrings((f) => f.toSupported),
.flatMap((c) => c.formatStrings((f) => f.toSupported)) )}
?.filter(
(format) => format !== ".svg" && format !== ".heif",
)}
<Dropdown <Dropdown
onselect={(r) => onselect={(r) =>
files.files.forEach((f) => { files.files.forEach((f) => {
f.to = r; if (f.from !== r) {
f.result = null; f.to = r;
f.result = null;
}
})} })}
options={supported || []} options={supported || []}
/> />

View File

@ -167,7 +167,8 @@
We can't convert this file. We can't convert this file.
</p> </p>
<p class="font-normal"> <p class="font-normal">
Only image, video, audio, and document files are supported Only image, video, audio, and document files are
supported
</p> </p>
</div> </div>
{/if} {/if}
@ -229,10 +230,7 @@
.flatMap((c) => .flatMap((c) =>
c.formatStrings((f) => f.toSupported), c.formatStrings((f) => f.toSupported),
) )
.filter( .filter((format) => format !== file.from) || []}
(format) =>
format !== ".svg" && format !== ".heif",
) || []}
bind:selected={file.to} bind:selected={file.to}
onselect={(option) => handleSelect(option, file)} onselect={(option) => handleSelect(option, file)}
/> />