Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions packages/ui/src/hooks/use-filtered-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,12 @@ export function useFilteredList<T>(props: FilteredListProps<T>) {
const [grouped, { refetch }] = createResource(
() => ({
filter: store.filter,
items:
typeof props.items === "function"
? props.items.length === 0
? (props.items as () => T[])()
: undefined
: props.items,
items: typeof props.items === "function" ? props.items(store.filter) : props.items,
}),
async ({ filter, items }) => {
const needle = filter?.toLowerCase()
const all = (items ?? (await (props.items as (filter: string) => T[] | Promise<T[]>)(needle))) || []
const query = filter ?? ""
const needle = query.toLowerCase()
const all = (await Promise.resolve(items)) || []
const result = pipe(
all,
(x) => {
Expand Down