11import { useQuery } from "@tanstack/react-query"
2- import { getApplicationsHost , getWorkspaceProxies } from "api/api"
2+ import { getWorkspaceProxies } from "api/api"
33import { Region } from "api/typesGenerated"
44import { useDashboard } from "components/Dashboard/DashboardProvider"
55import {
@@ -70,7 +70,6 @@ export const ProxyProvider: FC<PropsWithChildren> = ({ children }) => {
7070onSuccess :( resp ) => {
7171setAndSaveProxy ( proxy . selectedProxy , resp . regions )
7272} ,
73- enabled :experimentEnabled ,
7473} )
7574
7675const setAndSaveProxy = (
@@ -93,35 +92,20 @@ export const ProxyProvider: FC<PropsWithChildren> = ({ children }) => {
9392setProxy ( preferred )
9493}
9594
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-
11295return (
11396< ProxyContext . Provider
11497value = { {
11598proxy :experimentEnabled
11699 ?proxy
117100 :{
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 || [ ] ) ,
120104} ,
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 ,
125109// A function that takes the new proxies and selected proxy and updates
126110// the state with the appropriate urls.
127111setProxy :setAndSaveProxy ,