@@ -13,6 +13,13 @@ type DashboardItem =
1313 | SandboxFragmentDashboardFragment
1414 | SidebarCollectionDashboardFragment ;
1515
16+ // Type guard to check if an item is a sandbox
17+ function isSandbox (
18+ item : DashboardItem | { repository ?: any ; path ?: string }
19+ ) : item is SandboxFragmentDashboardFragment {
20+ return ! ( 'path' in item ) && ! ( 'repository' in item ) ;
21+ }
22+
1623// define which fields to search, with per-key thresholds & weights
1724const SEARCH_KEYS = [
1825 { name : 'title' , threshold : 0.2 , weight : 0.4 } ,
@@ -99,7 +106,7 @@ export const useGetItems = ({
99106 query : string ;
100107 username : string ;
101108 getFilteredSandboxes : (
102- list : DashboardItem [ ]
109+ list : SandboxFragmentDashboardFragment [ ]
103110 ) => SandboxFragmentDashboardFragment [ ] ;
104111} ) => {
105112 const state = useAppState ( ) ;
@@ -137,7 +144,7 @@ export const useGetItems = ({
137144 } , [ query , searchIndex ] ) ;
138145
139146 // then the rest is just your existing filtering / mapping logic:
140- const sandboxesInSearch = foundResults . filter ( s => ! ( s as any ) . path ) ;
147+ const sandboxesInSearch = foundResults . filter ( isSandbox ) ;
141148 const foldersInSearch = foundResults . filter ( s => ( s as any ) . path ) ;
142149 const filteredSandboxes = getFilteredSandboxes ( sandboxesInSearch ) ;
143150 const isLoadingQuery = query && ! searchIndex ;
0 commit comments