summaryrefslogtreecommitdiffhomepage
path: root/packages/ui/src/hooks
diff options
context:
space:
mode:
authorAdam <[email protected]>2025-12-14 19:33:40 -0600
committerAdam <[email protected]>2025-12-14 21:38:58 -0600
commit4246cdb069502c96ab11e260eb36a07a0370b710 (patch)
treea6340608c5d4954b860806ca807e95682385be96 /packages/ui/src/hooks
parent7ade6d386daeea120415b69f9df522001350db7b (diff)
downloadopencode-4246cdb069502c96ab11e260eb36a07a0370b710.tar.gz
opencode-4246cdb069502c96ab11e260eb36a07a0370b710.zip
wip(desktop): progress
Diffstat (limited to 'packages/ui/src/hooks')
-rw-r--r--packages/ui/src/hooks/use-filtered-list.tsx11
1 files changed, 7 insertions, 4 deletions
diff --git a/packages/ui/src/hooks/use-filtered-list.tsx b/packages/ui/src/hooks/use-filtered-list.tsx
index e3b373d4d..76a5ae84f 100644
--- a/packages/ui/src/hooks/use-filtered-list.tsx
+++ b/packages/ui/src/hooks/use-filtered-list.tsx
@@ -5,7 +5,7 @@ import { createStore } from "solid-js/store"
import { createList } from "solid-list"
export interface FilteredListProps<T> {
- items: (filter: string) => T[] | Promise<T[]>
+ items: T[] | ((filter: string) => T[] | Promise<T[]>)
key: (item: T) => string
filterKeys?: string[]
current?: T
@@ -19,10 +19,13 @@ export function useFilteredList<T>(props: FilteredListProps<T>) {
const [store, setStore] = createStore<{ filter: string }>({ filter: "" })
const [grouped, { refetch }] = createResource(
- () => store.filter,
- async (filter) => {
+ () => ({
+ filter: store.filter,
+ items: typeof props.items === "function" ? undefined : props.items,
+ }),
+ async ({ filter, items }) => {
const needle = filter?.toLowerCase()
- const all = (await props.items(needle)) || []
+ const all = (items ?? (await (props.items as (filter: string) => T[] | Promise<T[]>)(needle))) || []
const result = pipe(
all,
(x) => {