@@ -14,7 +14,6 @@ import type { ProxyContextValue } from "contexts/ProxyContext";
14
14
import { useWebpushNotifications } from "contexts/useWebpushNotifications" ;
15
15
import { useEmbeddedMetadata } from "hooks/useEmbeddedMetadata" ;
16
16
import { NotificationsInbox } from "modules/notifications/NotificationsInbox/NotificationsInbox" ;
17
- import type { Task } from "modules/tasks/tasks" ;
18
17
import { data } from "pages/TasksPage/TasksPage" ;
19
18
import type { FC } from "react" ;
20
19
import { useQuery } from "react-query" ;
@@ -161,15 +160,15 @@ const NavItems: FC<NavItemsProps> = ({ className, user }) => {
161
160
if ( location . pathname . startsWith ( "/@" ) ) {
162
161
isActive = true ;
163
162
}
164
- return cn ( linkStyles . default , isActive ? linkStyles . active : "" ) ;
163
+ return cn ( linkStyles . default , { [ linkStyles . active ] : isActive } ) ;
165
164
} }
166
165
to = "/workspaces"
167
166
>
168
167
Workspaces
169
168
</ NavLink >
170
169
< NavLink
171
170
className = { ( { isActive} ) => {
172
- return cn ( linkStyles . default , isActive ? linkStyles . active : "" ) ;
171
+ return cn ( linkStyles . default , { [ linkStyles . active ] : isActive } ) ;
173
172
} }
174
173
to = "/templates"
175
174
>
@@ -198,58 +197,51 @@ const TasksNavItem: FC<TasksNavItemProps> = ({ user }) => {
198
197
avatarUrl :user . avatar_url ,
199
198
} ,
200
199
} ;
201
- const { data :idleTasks } = useQuery ( {
200
+ const { data :idleCount } = useQuery ( {
202
201
queryKey :[ "tasks" , filter ] ,
203
202
queryFn :( ) => data . fetchTasks ( filter ) ,
204
203
refetchInterval :1_000 * 60 ,
205
204
enabled :canSeeTasks ,
206
205
refetchOnWindowFocus :true ,
206
+ initialData :[ ] ,
207
207
select :( data ) =>
208
- data . filter ( ( task ) => task . workspace . latest_app_status ?. state === "idle" ) ,
208
+ data . filter ( ( task ) => task . workspace . latest_app_status ?. state === "idle" )
209
+ . length ,
209
210
} ) ;
210
211
211
212
if ( ! canSeeTasks ) {
212
213
return null ;
213
214
}
214
215
215
- const search =
216
- idleTasks && idleTasks . length > 0
217
- ?new URLSearchParams ( {
218
- username :user . username ,
219
- tab :"waiting-for-input" ,
220
- } ) . toString ( )
221
- :undefined ;
222
-
223
216
return (
224
217
< NavLink
225
- to = { { pathname : "/tasks" , search } }
218
+ to = "/tasks"
226
219
className = { ( { isActive} ) => {
227
- return cn ( linkStyles . default , isActive ? linkStyles . active : "" ) ;
220
+ return cn ( linkStyles . default , { [ linkStyles . active ] : isActive } ) ;
228
221
} }
229
222
>
230
223
Tasks
231
- { idleTasks && idleTasks . length > 0 && (
224
+ { idleCount > 0 && (
232
225
< TooltipProvider >
233
226
< Tooltip >
234
227
< TooltipTrigger asChild >
235
228
< Badge
236
229
variant = "info"
237
230
size = "xs"
238
231
className = "ml-2"
239
- aria-label = { idleTasksLabel ( idleTasks ) }
232
+ aria-label = { idleTasksLabel ( idleCount ) }
240
233
>
241
- { idleTasks . length }
234
+ { idleCount }
242
235
</ Badge >
243
236
</ TooltipTrigger >
244
- < TooltipContent > { idleTasksLabel ( idleTasks ) } </ TooltipContent >
237
+ < TooltipContent > { idleTasksLabel ( idleCount ) } </ TooltipContent >
245
238
</ Tooltip >
246
239
</ TooltipProvider >
247
240
) }
248
241
</ NavLink >
249
242
) ;
250
243
} ;
251
244
252
- function idleTasksLabel ( idleTasks :Task [ ] ) {
253
- const count = idleTasks . length ;
245
+ function idleTasksLabel ( count :number ) {
254
246
return `You have${ count } ${ count === 1 ?"task" :"tasks" } waiting for input` ;
255
247
}