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 (