From ff7456b8b94c211252f924b6a8a87bb10f626deb Mon Sep 17 00:00:00 2001 From: Maya Date: Sat, 21 Feb 2026 19:49:34 +0300 Subject: [PATCH] fix: all categories/formats fallback fall back to showing everything if there is no formats returned for some reason & add more logging. some people are seeing this for some reason and idk why --- messages/en.json | 3 +- .../functional/FormatDropdown.svelte | 60 ++++++++++++++++++- src/routes/convert/+page.svelte | 1 - 3 files changed, 60 insertions(+), 4 deletions(-) diff --git a/messages/en.json b/messages/en.json index fc2e363..82791cf 100644 --- a/messages/en.json +++ b/messages/en.json @@ -79,7 +79,8 @@ "image": "Image", "placeholder": "Search format", "no_formats": "No formats available", - "no_results": "No formats match your search" + "no_results": "No formats match your search", + "fallback": "An error occurred loading available categories & formats, showing everything." }, "settings": { "settings": "Settings", diff --git a/src/lib/components/functional/FormatDropdown.svelte b/src/lib/components/functional/FormatDropdown.svelte index 2dc23ff..6ebcd05 100644 --- a/src/lib/components/functional/FormatDropdown.svelte +++ b/src/lib/components/functional/FormatDropdown.svelte @@ -9,6 +9,7 @@ import { quintOut } from "svelte/easing"; import { VertFile } from "$lib/types"; import SettingsModal from "./SettingsModal.svelte"; + import { log } from "$lib/util/logger"; type Props = { categories: Categories; @@ -41,6 +42,11 @@ $effect(() => { if (currentCategory) return; + log( + ["dropdown", "init"], + `initializing category, file: ${file?.name}, from: ${from}`, + ); + // find the category whose formats overlap most with the converters for this file (or all files) // this finds the best matching category based on the formats supported by the converters const pickCategoryFromConverters = ( @@ -72,6 +78,12 @@ : file.converters : files.files.flatMap((f) => f.converters); + log( + ["dropdown", "init"], + `checking converters:`, + convertersToCheck.map((c) => c.formatStrings()), + ); + // if file is provided, first try to find its category by input format let detectedCategory: string | null = null; if (file && from) { @@ -79,6 +91,11 @@ Object.keys(categories).find((cat) => categories[cat].formats.includes(from), ) || null; + log( + ["dropdown", "init"], + `detected category from input format (${from}):`, + detectedCategory, + ); } // fallback to category with most converter overlap if input category not found @@ -87,6 +104,8 @@ pickCategoryFromConverters(convertersToCheck) || Object.keys(categories)[0]; + log(["dropdown", "init"], `final detected category:`, detectedCategory); + currentCategory = detectedCategory; rootCategory = detectedCategory; }); @@ -143,9 +162,33 @@ ) : []; + // if no formats found at all, show everything + if (formats.length !== 0) { + const allCategories = Object.keys(categories); + // show formats for current category if set, otherwise all formats + const fallbackFormats = + currentCategory && allCategories.includes(currentCategory) + ? categories[currentCategory].formats + : allCategories.flatMap( + (cat) => categories[cat].formats, + ); + + log( + ["dropdown", "filter"], + `no formats found for category ${currentCategory}, showing all categories and formats as fallback`, + ); + + return { + categories: allCategories, + formats: fallbackFormats, + isFallback: true, + }; + } + return { categories: availableCategories, formats, + isFallback: false, }; } const searchLower = normalize(searchQuery); @@ -162,6 +205,7 @@ return { categories: availableCategories, formats: [], + isFallback: false, }; } @@ -198,6 +242,7 @@ ? matchingCategories : availableCategories, formats: filteredFormats, + isFallback: false, }; }); @@ -451,16 +496,21 @@ {}} id="format-search" autocomplete="off" + disabled={filteredData.isFallback} /> @@ -477,6 +527,12 @@ {/if} + + {#if filteredData.isFallback} +
+ {m["convert.dropdown.fallback"]()} +
+ {/if}
{#each filteredData.categories as category} diff --git a/src/routes/convert/+page.svelte b/src/routes/convert/+page.svelte index b93ce0c..2a8a9ce 100644 --- a/src/routes/convert/+page.svelte +++ b/src/routes/convert/+page.svelte @@ -32,7 +32,6 @@ import { Settings } from "$lib/sections/settings/index.svelte"; import { MAX_ARRAY_BUFFER_SIZE } from "$lib/store/index.svelte"; import { GB } from "$lib/util/consts"; - import { log } from "$lib/util/logger"; let processedFileIds = $state(new Set());