Skip to content

Commit 1697b42

Browse files
fix: restore original proxy auto-selection logic
Revert useEffect dependency arrays to match main branch behavior: - Remove userSavedProxy from dependency arrays - Call loadUserSelectedProxy() directly in auto-selection logic - This ensures auto-selection works when no user proxy is saved Co-authored-by: kylecarbs <7122116+kylecarbs@users.noreply.github.com>
1 parent 15a7819 commit 1697b42

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

site/src/contexts/ProxyContext.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ export const ProxyProvider: FC<PropsWithChildren> = ({ children }) => {
156156
// biome-ignore lint/correctness/useExhaustiveDependencies: Only update if the source data changes
157157
useEffect(() => {
158158
updateProxy();
159-
}, [proxiesResp, proxyLatencies, userSavedProxy]);
159+
}, [proxiesResp, proxyLatencies]);
160160

161161
// This useEffect will auto select the best proxy if the user has not selected one.
162162
// It must wait until all latencies are loaded to select based on latency. This does mean
@@ -165,7 +165,7 @@ export const ProxyProvider: FC<PropsWithChildren> = ({ children }) => {
165165
// Once the page is loaded, or the user selects a proxy, this will not run again.
166166
// biome-ignore lint/correctness/useExhaustiveDependencies: Only update if the source data changes
167167
useEffect(() => {
168-
if (userSavedProxy !== undefined) {
168+
if (loadUserSelectedProxy() !== undefined) {
169169
return; // User has selected a proxy, do not auto select.
170170
}
171171
if (!latenciesLoaded) {
@@ -175,7 +175,7 @@ export const ProxyProvider: FC<PropsWithChildren> = ({ children }) => {
175175

176176
const best = getPreferredProxy(
177177
proxiesResp ?? [],
178-
userSavedProxy,
178+
loadUserSelectedProxy(),
179179
proxyLatencies,
180180
true,
181181
);
@@ -184,7 +184,7 @@ export const ProxyProvider: FC<PropsWithChildren> = ({ children }) => {
184184
saveUserSelectedProxy(best.proxy);
185185
updateProxy();
186186
}
187-
}, [latenciesLoaded, proxiesResp, proxyLatencies, userSavedProxy]);
187+
}, [latenciesLoaded, proxiesResp, proxyLatencies]);
188188

189189
return (
190190
<ProxyContext.Provider

0 commit comments

Comments
 (0)