From 05263d10894e421a8a5b25829bbb37c813313248 Mon Sep 17 00:00:00 2001 From: John Costa Date: Sat, 8 Mar 2025 15:50:21 +0000 Subject: [PATCH] fix: actually searching properly --- frontend/src/App.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 496a46f..07eecb8 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -17,7 +17,7 @@ function App() { const nav = useNavigate(); - let fuze = new Fuse([], { keys: ["Text.ImageText"] }); + let fuze = new Fuse[number]>([], { keys: ["Text.ImageText"] }); // TODO: there's probably a better way? createEffect(() => { @@ -26,13 +26,15 @@ function App() { return; } - fuze = new Fuse(userImages, { keys: ["Text.ImageText"] }); + const imageText = userImages.flatMap(i => i.Text ?? []); + + fuze = new Fuse(imageText, { keys: ["ImageText"], threshold: 0.3 }); }); const onInputChange = (query: string) => { // TODO: we can migrate this searching to Rust, so we don't abuse the main thread. - const searched = fuze.search(query).flatMap(s => s.item).flatMap(s => s.Text ?? []); - setSearchResults(searched); + // But, it's not too bad as is. + setSearchResults(fuze.search(query).flatMap(s => s.item)); } return (