@cripty2001/utils 0.0.182 → 0.0.183
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/react-whispr.js +5 -6
- package/package.json +1 -1
package/dist/react-whispr.js
CHANGED
|
@@ -281,24 +281,23 @@ function getRelTimeFormat(_diff) {
|
|
|
281
281
|
* - A boolean indicating if the search is pending
|
|
282
282
|
*/
|
|
283
283
|
function useSearcher(data, limit) {
|
|
284
|
+
const searcher = (0, react_1.useRef)(new Searcher_1.Searcher(data));
|
|
285
|
+
(0, react_1.useEffect)(() => {
|
|
286
|
+
searcher.current.updateData(data);
|
|
287
|
+
}, [data]);
|
|
284
288
|
const [pending, setPending] = (0, react_1.useState)(false);
|
|
285
289
|
const [results, setResults] = (0, react_1.useState)({
|
|
286
|
-
results:
|
|
290
|
+
results: searcher.current.search("", limit),
|
|
287
291
|
_meta: {
|
|
288
292
|
ts: 0,
|
|
289
293
|
config: { q: "" }
|
|
290
294
|
}
|
|
291
295
|
});
|
|
292
|
-
const searcher = (0, react_1.useRef)(new Searcher_1.Searcher(data));
|
|
293
|
-
(0, react_1.useEffect)(() => {
|
|
294
|
-
searcher.current.updateData(data);
|
|
295
|
-
}, [data]);
|
|
296
296
|
const [q, setQ] = useAsyncInput(results, setResults, async ({ q }) => {
|
|
297
297
|
return {
|
|
298
298
|
results: searcher.current.search(q, limit)
|
|
299
299
|
};
|
|
300
300
|
}, setPending);
|
|
301
|
-
setQ(draft => { draft.q = ""; }); // Running the first search with the empty query
|
|
302
301
|
return [
|
|
303
302
|
q.q,
|
|
304
303
|
(q) => setQ(draft => { draft.q = q; }),
|
package/package.json
CHANGED