From 01e417ed08a8327169e6488a557c46b6a7b97a08 Mon Sep 17 00:00:00 2001
From: Pinapelz <yukais@pinapelz.com>
Date: Sun, 7 Jun 2026 21:25:28 -0700
Subject: bundle song list statically, improve search time

---
 src/components/Search/index.tsx | 27 ++++++++-------------------
 1 file changed, 8 insertions(+), 19 deletions(-)

(limited to 'src/components/Search/index.tsx')

diff --git a/src/components/Search/index.tsx b/src/components/Search/index.tsx
index 7f9d502..4d1ae83 100644
--- a/src/components/Search/index.tsx
+++ b/src/components/Search/index.tsx
@@ -11,30 +11,18 @@ interface Props {
 }
 
 export function Search({ currentTry, setSelectedSong }: Props) {
-  const [value, setValue] = React.useState<string>("");
+  const [value, setValue] = React.useState("");
   const [results, setResults] = React.useState<Song[]>([]);
 
   React.useEffect(() => {
-    let cancelled = false;
-
-    async function runSearch() {
-      if (!value) {
-        setResults([]);
-        return;
-      }
-      const songs = await searchSong(value);
-
-      if (!cancelled) {
-        setResults(songs);
-      }
+    if (!value.trim()) {
+      setResults([]);
+      return;
     }
-    runSearch();
-    return () => {
-      cancelled = true;
-    };
+
+    setResults(searchSong(value));
   }, [value]);
 
-  // clear value on selection
   React.useEffect(() => {
     setValue("");
   }, [currentTry]);
@@ -57,13 +45,14 @@ export function Search({ currentTry, setSelectedSong }: Props) {
           </Styled.Result>
         ))}
       </Styled.ResultsContainer>
+
       <Styled.SearchContainer>
         <Styled.SearchPadding>
           <IoSearch size={20} />
           <Styled.Input
+            value={value}
             onChange={(e) => setValue(e.currentTarget.value)}
             placeholder="Search"
-            value={value}
           />
         </Styled.SearchPadding>
       </Styled.SearchContainer>
-- 
cgit v1.2.3

