fix: actually searching properly
This commit is contained in:
@ -17,7 +17,7 @@ function App() {
|
|||||||
|
|
||||||
const nav = useNavigate();
|
const nav = useNavigate();
|
||||||
|
|
||||||
let fuze = new Fuse<UserImages>([], { keys: ["Text.ImageText"] });
|
let fuze = new Fuse<NonNullable<UserImages[number]['Text']>[number]>([], { keys: ["Text.ImageText"] });
|
||||||
|
|
||||||
// TODO: there's probably a better way?
|
// TODO: there's probably a better way?
|
||||||
createEffect(() => {
|
createEffect(() => {
|
||||||
@ -26,13 +26,15 @@ function App() {
|
|||||||
return;
|
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) => {
|
const onInputChange = (query: string) => {
|
||||||
// TODO: we can migrate this searching to Rust, so we don't abuse the main thread.
|
// 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 ?? []);
|
// But, it's not too bad as is.
|
||||||
setSearchResults(searched);
|
setSearchResults(fuze.search(query).flatMap(s => s.item));
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
Reference in New Issue
Block a user