fix(app): file search
This commit is contained in:
@@ -22,18 +22,10 @@ export function useFilteredList<T>(props: FilteredListProps<T>) {
|
|||||||
const empty: Group[] = []
|
const empty: Group[] = []
|
||||||
|
|
||||||
const [grouped, { refetch }] = createResource(
|
const [grouped, { refetch }] = createResource(
|
||||||
() => {
|
() => ({
|
||||||
// When items is a function (not async filter function), call it to track changes
|
filter: store.filter,
|
||||||
const itemsValue =
|
items: typeof props.items === "function" ? undefined : props.items,
|
||||||
typeof props.items === "function"
|
}),
|
||||||
? (props.items as () => T[])() // Call synchronous function to track it
|
|
||||||
: props.items
|
|
||||||
|
|
||||||
return {
|
|
||||||
filter: store.filter,
|
|
||||||
items: itemsValue,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
async ({ filter, items }) => {
|
async ({ filter, items }) => {
|
||||||
const needle = filter?.toLowerCase()
|
const needle = filter?.toLowerCase()
|
||||||
const all = (items ?? (await (props.items as (filter: string) => T[] | Promise<T[]>)(needle))) || []
|
const all = (items ?? (await (props.items as (filter: string) => T[] | Promise<T[]>)(needle))) || []
|
||||||
|
|||||||
Reference in New Issue
Block a user