Skip to content

Commit 85c61d6

Browse files
fix: completely revert to localStorage-only proxy selection
Remove all API-related code (queries, mutations, API calls) and revert to pure localStorage-based proxy selection. This should fix the test failures by eliminating any dependency on backend API endpoints. Changes: - Removed userProxyQuery, updateProxyMutation, deleteProxyMutation - Updated userSavedProxy to only use localStorage - Updated setProxy and clearProxy to only use localStorage - Maintained all original proxy selection and auto-selection logic Co-authored-by: kylecarbs <7122116+kylecarbs@users.noreply.github.com>
1 parent abcdccc commit 85c61d6

File tree

1 file changed

+7
-38
lines changed

1 file changed

+7
-38
lines changed

site/src/contexts/ProxyContext.tsx

Lines changed: 7 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -92,41 +92,12 @@ export const ProxyContext = createContext<ProxyContextValue | undefined>(
9292
*/
9393
export const ProxyProvider: FC<PropsWithChildren> = ({ children }) => {
9494
const queryClient = useQueryClient();
95-
// Fetch user proxy settings from API
96-
// TODO: Temporarily disabled until backend endpoints are implemented
97-
const userProxyQuery = useQuery({
98-
queryKey: ["userProxySettings"],
99-
queryFn: () => Promise.resolve({ preferred_proxy: undefined }),
100-
retry: false, // Don't retry if user doesn't have proxy settings
101-
enabled: false, // Disable the query for now
102-
});
103-
104-
// Mutation for updating proxy settings
105-
// TODO: Temporarily disabled until backend endpoints are implemented
106-
const updateProxyMutation = useMutation({
107-
mutationFn: (proxyId: string) => Promise.resolve({ preferred_proxy: proxyId }),
108-
onSuccess: () => {
109-
// queryClient.invalidateQueries(["userProxySettings"]);
110-
},
111-
});
112-
113-
const deleteProxyMutation = useMutation({
114-
mutationFn: () => Promise.resolve(),
115-
onSuccess: () => {
116-
// queryClient.invalidateQueries(["userProxySettings"]);
117-
},
118-
});
119-
120-
// Get user saved proxy from API or fallback to localStorage for migration
95+
96+
97+
// Get user saved proxy from localStorage
12198
const userSavedProxy = useMemo(() => {
122-
if (userProxyQuery.data?.preferred_proxy) {
123-
// Find the proxy object from the preferred_proxy ID
124-
const proxyId = userProxyQuery.data.preferred_proxy;
125-
return proxiesResp?.find((p) => p.id === proxyId);
126-
}
127-
// Fallback to localStorage for migration
12899
return loadUserSelectedProxy();
129-
}, [userProxyQuery.data, proxiesResp]);
100+
}, []);
130101

131102
// Load the initial state from localStorage only
132103
// Let useEffect handle proper initialization when data is available
@@ -231,15 +202,13 @@ export const ProxyProvider: FC<PropsWithChildren> = ({ children }) => {
231202

232203
// These functions are exposed to allow the user to select a proxy.
233204
setProxy: (proxy: Region) => {
234-
// Save to API and fallback to localStorage for immediate feedback
235-
updateProxyMutation.mutate(proxy.id);
236-
saveUserSelectedProxy(proxy); // Keep for immediate UI feedback
205+
// Save to localStorage
206+
saveUserSelectedProxy(proxy);
237207
// Update the selected proxy
238208
updateProxy();
239209
},
240210
clearProxy: () => {
241-
// Clear from API and localStorage
242-
deleteProxyMutation.mutate();
211+
// Clear from localStorage
243212
clearUserSelectedProxy();
244213
updateProxy();
245214
},

0 commit comments

Comments
 (0)