fix: open native category first

This commit is contained in:
Maya 2026-02-18 09:35:30 +03:00
parent 4fca8a9696
commit f129682474
2 changed files with 14 additions and 6 deletions

View File

@ -8,9 +8,6 @@
import { onMount } from "svelte";
import { quintOut } from "svelte/easing";
import { VertFile } from "$lib/types";
import Modal from "./Modal.svelte";
import Dropdown from "./Dropdown.svelte";
import FancyInput from "./FancyInput.svelte";
import SettingsModal from "./SettingsModal.svelte";
type Props = {
@ -75,9 +72,18 @@
: file.converters
: files.files.flatMap((f) => f.converters);
// pick the best matching category, or fall back to first category
// TODO: if something fails for some reason, maybe show all categories?
const detectedCategory =
// if file is provided, first try to find its category by input format
let detectedCategory: string | null = null;
if (file && from) {
detectedCategory =
Object.keys(categories).find((cat) =>
categories[cat].formats.includes(from),
) || null;
}
// fallback to category with most converter overlap if input category not found
detectedCategory =
detectedCategory ||
pickCategoryFromConverters(convertersToCheck) ||
Object.keys(categories)[0];

View File

@ -164,6 +164,7 @@ export class FFmpegConverter extends Converter {
default: audioTracks ?? 1,
min: 1,
max: audioTracks ? audioTracks : 1,
placeholder: audioTracks ?? 1
};
const audioChannels = await this.detectAudioChannels(ffmpeg);
@ -174,6 +175,7 @@ export class FFmpegConverter extends Converter {
default: audioChannels ?? 2,
min: 1,
max: audioChannels ? audioChannels * 2 : 5,
placeholder: audioChannels ?? 2
};
const metadata: SettingDefinition = {