Make filteredQueryResultsSelector async :)

This commit is contained in:
rektdeckard
2020-07-24 14:38:53 -04:00
parent f14ff1ea4f
commit 8ae4cb2b81
3 changed files with 53 additions and 24 deletions

View File

@@ -21,16 +21,15 @@ const isQueryMatch = (icon: IconEntry, query: string): boolean => {
export const filteredQueryResultsSelector = selector<Readonly<IconEntry[]>>({
key: "filteredQueryResultsSelector",
get: ({ get }) => {
get: async ({ get }) => {
const query = get(searchQueryAtom).trim().toLowerCase();
const style = get(styleQueryAtom);
if (!query && !style) return icons;
return icons.filter((icon) => {
return isQueryMatch(icon, query);
});
// .sort(() => Math.floor(Math.random() - 0.5));
return await new Promise((resolve) =>
resolve(icons.filter((icon) => isQueryMatch(icon, query)))
);
},
});