From 00267da3dd30177d053463fbc7b8cd31008b73cf Mon Sep 17 00:00:00 2001 From: David Alvarez Date: Wed, 27 May 2026 11:57:16 +0200 Subject: [PATCH] fix: manual title input searches IGDB first, warns before uploading MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Flow when auto-search finds nothing: 1. User types a title → presses Enter/clicks button 2. System searches IGDB with that title 3a. Results found → shown as selectable cards 3b. No results → warning + amber 'Upload anyway as xxx' button 4. Button label changes: 'Search' → 'Upload' after manual search Also changed Enter key behavior: first press searches, second press uploads (if no results after manual search) --- frontend/src/pages/Library.svelte | 38 ++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/frontend/src/pages/Library.svelte b/frontend/src/pages/Library.svelte index 76ea009..159f9bd 100644 --- a/frontend/src/pages/Library.svelte +++ b/frontend/src/pages/Library.svelte @@ -15,6 +15,7 @@ let searching = $state(false); let searchError = $state(""); let igdbResults = $state(null); // null=loading, []=no results, [{...}]=matches + let manualSearched = $state(false); // true after user clicked Search manually let fileInput; @@ -39,6 +40,7 @@ igdbResults = null; searching = true; searchError = ""; + manualSearched = false; fileInput.value = ""; // Auto-search IGDB with the filename searchIGDB(name).then(data => { @@ -54,6 +56,7 @@ async function handleManualSearch() { const q = pendingTitle.trim(); if (!q) return; + manualSearched = true; searching = true; searchError = ""; igdbResults = null; @@ -61,7 +64,7 @@ const data = await searchIGDB(q); igdbResults = data.results || []; if (igdbResults.length === 0) { - searchError = "No matches found on IGDB."; + searchError = "No matches found for \"" + q + "\" on IGDB."; } } catch (err) { searchError = "IGDB search failed: " + err.message; @@ -76,6 +79,7 @@ pendingTitle = ""; igdbResults = null; searchError = ""; + manualSearched = false; } async function doUpload(title) { @@ -173,20 +177,27 @@ {:else} {#if searchError} -
{searchError}
+
+ {searchError} + {#if manualSearched} + + {/if} +
{:else} -

No matches found on IGDB. Enter a title manually:

+

No matches found. Enter a title to search IGDB:

{/if}
e.key === "Enter" && doUpload(pendingTitle.trim())} + disabled={uploading || searching} + onkeydown={(e) => e.key === "Enter" && (manualSearched ? doUpload(pendingTitle.trim()) : handleManualSearch())} /> -