mirror of
https://github.com/artegoser/AnoPaper.git
synced 2024-11-22 03:46:22 +03:00
perf: not indexing every render
This commit is contained in:
parent
0b7523c57d
commit
548b2955cd
1 changed files with 7 additions and 6 deletions
|
@ -22,12 +22,11 @@ function Notes() {
|
|||
|
||||
let n = Object.values(localStorage.getObj("Notes"));
|
||||
|
||||
let [search, setSearch] = useState("");
|
||||
const [search, setSearch] = useState("");
|
||||
const [indexed, setIndexed] = useState(false);
|
||||
|
||||
let fuse;
|
||||
|
||||
if (search)
|
||||
fuse = new Fuse(n, {
|
||||
if (search && !indexed) {
|
||||
window.fuseIndex = new Fuse(n, {
|
||||
includeScore: true,
|
||||
useExtendedSearch: true,
|
||||
keys: [
|
||||
|
@ -39,8 +38,10 @@ function Notes() {
|
|||
},
|
||||
],
|
||||
});
|
||||
setIndexed(true);
|
||||
}
|
||||
|
||||
let found = search === "" ? n : fuse.search(search);
|
||||
let found = search === "" ? n : window.fuseIndex.search(search);
|
||||
|
||||
if (search !== "") {
|
||||
found = found
|
||||
|
|
Loading…
Add table
Reference in a new issue