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

Commitffbeed9

Browse files
fix: use useState for userSavedProxy to make it reactive
- Change userSavedProxy from useMemo to useState to make it reactive to changes- Update setUserSavedProxy when auto-selecting proxy or manually setting/clearing- This ensures userProxy in context reflects current localStorage state- Matches main branch behavior where userSavedProxy was a useStateCo-authored-by: kylecarbs <7122116+kylecarbs@users.noreply.github.com>
1 parent8c2b457 commitffbeed9

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

‎site/src/contexts/ProxyContext.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,9 @@ export const ProxyContext = createContext<ProxyContextValue | undefined>(
9393
exportconstProxyProvider:FC<PropsWithChildren>=({ children})=>{
9494
constqueryClient=useQueryClient();
9595

96-
// Get user saved proxy from localStorage
97-
constuserSavedProxy=useMemo(()=>{
98-
returnloadUserSelectedProxy();
99-
},[]);
96+
// Using a useState so the caller always has the latest user saved
97+
// proxy.
98+
const[userSavedProxy,setUserSavedProxy]=useState(loadUserSelectedProxy());
10099

101100
// Load the initial state from localStorage only
102101
// Let useEffect handle proper initialization when data is available
@@ -182,6 +181,7 @@ export const ProxyProvider: FC<PropsWithChildren> = ({ children }) => {
182181

183182
if(best?.proxy){
184183
saveUserSelectedProxy(best.proxy);
184+
setUserSavedProxy(best.proxy);
185185
updateProxy();
186186
}
187187
},[latenciesLoaded,proxiesResp,proxyLatencies]);
@@ -203,12 +203,14 @@ export const ProxyProvider: FC<PropsWithChildren> = ({ children }) => {
203203
setProxy:(proxy:Region)=>{
204204
// Save to localStorage
205205
saveUserSelectedProxy(proxy);
206+
setUserSavedProxy(proxy);
206207
// Update the selected proxy
207208
updateProxy();
208209
},
209210
clearProxy:()=>{
210211
// Clear from localStorage
211212
clearUserSelectedProxy();
213+
setUserSavedProxy(undefined);
212214
updateProxy();
213215
},
214216
}}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp