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

View File

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