Skip to content

Commit 42a3450

Browse files
committed
refactor: adjust workspace state polling and retry behavior based on authentication
1 parent 399a82a commit 42a3450

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/frontend/src/api/hooks.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,16 @@ export function useUserProfile(options?: UseQueryOptions<UserProfile>) {
132132
}
133133

134134
export function useWorkspaceState(options?: UseQueryOptions<WorkspaceState>) {
135+
// Get the current auth state from the query cache
136+
const authState = queryClient.getQueryData<boolean>(['auth']);
137+
135138
return useQuery({
136139
queryKey: ['workspaceState'],
137140
queryFn: api.getWorkspaceState,
138-
refetchInterval: 5000, // Poll every 5 seconds
141+
// Only poll if authenticated
142+
refetchInterval: authState === true ? 5000 : false, // Poll every 5 seconds if authenticated, otherwise don't poll
143+
// Don't retry on error if not authenticated
144+
retry: authState === true ? 1 : false,
139145
...options,
140146
});
141147
}

0 commit comments

Comments
 (0)