1
1
import { useQuery } from "@tanstack/react-query"
2
- import { getApplicationsHost , getWorkspaceProxies } from "api/api"
2
+ import { getWorkspaceProxies } from "api/api"
3
3
import { Region } from "api/typesGenerated"
4
4
import { useDashboard } from "components/Dashboard/DashboardProvider"
5
5
import {
@@ -70,7 +70,6 @@ export const ProxyProvider: FC<PropsWithChildren> = ({ children }) => {
70
70
onSuccess : ( resp ) => {
71
71
setAndSaveProxy ( proxy . selectedProxy , resp . regions )
72
72
} ,
73
- enabled : experimentEnabled ,
74
73
} )
75
74
76
75
const setAndSaveProxy = (
@@ -93,35 +92,20 @@ export const ProxyProvider: FC<PropsWithChildren> = ({ children }) => {
93
92
setProxy ( preferred )
94
93
}
95
94
96
- // ******************************* //
97
- // ** This code can be removed **
98
- // ** when the experimental is **
99
- // ** dropped ** //
100
- const appHostQueryKey = [ "get-application-host" ]
101
- const {
102
- data : applicationHostResult ,
103
- error : appHostError ,
104
- isLoading : appHostLoading ,
105
- isFetched : appHostFetched ,
106
- } = useQuery ( {
107
- queryKey : appHostQueryKey ,
108
- queryFn : getApplicationsHost ,
109
- enabled : ! experimentEnabled ,
110
- } )
111
-
112
95
return (
113
96
< ProxyContext . Provider
114
97
value = { {
115
98
proxy : experimentEnabled
116
99
? proxy
117
100
: {
118
- ...getPreferredProxy ( [ ] ) ,
119
- preferredWildcardHostname : applicationHostResult ?. host || "" ,
101
+ // If the experiment is disabled, then call 'getPreferredProxy' with the regions from
102
+ // the api call. The default behavior is to use the `primary` proxy.
103
+ ...getPreferredProxy ( proxiesResp ?. regions || [ ] ) ,
120
104
} ,
121
- proxies : experimentEnabled ? proxiesResp ?. regions : [ ] ,
122
- isLoading : experimentEnabled ? proxiesLoading : appHostLoading ,
123
- isFetched : experimentEnabled ? proxiesFetched : appHostFetched ,
124
- error : experimentEnabled ? proxiesError : appHostError ,
105
+ proxies : proxiesResp ?. regions ,
106
+ isLoading : proxiesLoading ,
107
+ isFetched : proxiesFetched ,
108
+ error : proxiesError ,
125
109
// A function that takes the new proxies and selected proxy and updates
126
110
// the state with the appropriate urls.
127
111
setProxy : setAndSaveProxy ,
0 commit comments