fix: actually searching properly
This commit is contained in:
@ -17,7 +17,7 @@ function App() {
|
||||
|
||||
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?
|
||||
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 (
|
||||
|
Reference in New Issue
Block a user