File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed
Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -132,10 +132,16 @@ export function useUserProfile(options?: UseQueryOptions<UserProfile>) {
132132}
133133
134134export 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}
You can’t perform that action at this time.
0 commit comments