Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit93bc6b3

Browse files
committed
fmt
1 parentdcf98d7 commit93bc6b3

File tree

3 files changed

+18
-11
lines changed

3 files changed

+18
-11
lines changed

‎site/src/contexts/ProxyContext.test.tsx‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ import type * as ProxyLatency from "./useProxyLatency";
2626
// here and not inside a unit test.
2727
jest.mock("contexts/useProxyLatency",()=>({
2828
useProxyLatency:()=>{
29-
return{proxyLatencies:hardCodedLatencies,refetch:jest.fn(),loaded:true};
29+
return{
30+
proxyLatencies:hardCodedLatencies,
31+
refetch:jest.fn(),
32+
loaded:true,
33+
};
3034
},
3135
}));
3236

‎site/src/contexts/ProxyContext.tsx‎

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,11 @@ export const ProxyProvider: FC<PropsWithChildren> = ({ children }) => {
122122

123123
// Every time we get a new proxiesResponse, update the latency check
124124
// to each workspace proxy.
125-
const{ proxyLatencies,refetch:refetchProxyLatencies,loaded:latenciesLoaded}=
126-
useProxyLatency(proxiesResp);
125+
const{
126+
proxyLatencies,
127+
refetch:refetchProxyLatencies,
128+
loaded:latenciesLoaded,
129+
}=useProxyLatency(proxiesResp);
127130

128131
// updateProxy is a helper function that when called will
129132
// update the proxy being used.
@@ -153,13 +156,14 @@ export const ProxyProvider: FC<PropsWithChildren> = ({ children }) => {
153156
// This useEffect will auto select the best proxy if the user has not selected one.
154157
// It must wait until all latencies are loaded to select based on latency. This does mean
155158
// the first time a user loads the page, the proxy will "flicker" to the best proxy.
156-
//
159+
//
157160
// Once the page is loaded, or the user selects a proxy, this will not run again.
161+
// biome-ignore lint/correctness/useExhaustiveDependencies: Only update if the source data changes
158162
useEffect(()=>{
159-
if(loadUserSelectedProxy()!==undefined){
163+
if(loadUserSelectedProxy()!==undefined){
160164
return;// User has selected a proxy, do not auto select.
161165
}
162-
if(!latenciesLoaded){
166+
if(!latenciesLoaded){
163167
// Wait until the latencies are loaded before
164168
return;
165169
}
@@ -171,12 +175,11 @@ export const ProxyProvider: FC<PropsWithChildren> = ({ children }) => {
171175
true,
172176
);
173177

174-
if(best?.proxy){
178+
if(best?.proxy){
175179
saveUserSelectedProxy(best.proxy);
176180
updateProxy();
177181
}
178-
179-
},[latenciesLoaded])
182+
},[latenciesLoaded,proxiesResp,proxyLatencies]);
180183

181184
return(
182185
<ProxyContext.Provider
@@ -250,7 +253,7 @@ export const getPreferredProxy = (
250253
}
251254

252255
// Use the primary proxy if we don't have any other options.
253-
if(!selectedProxy){
256+
if(!selectedProxy){
254257
selectedProxy=proxies.find((proxy)=>proxy.name==="primary");
255258
}
256259
}

‎site/src/contexts/useProxyLatency.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ export const useProxyLatency = (
245245
return{
246246
proxyLatencies,
247247
refetch,
248-
loaded
248+
loaded,
249249
};
250250
};
251251

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp