From 658312fe7be95d69b4dad379c6cd00fc93f29d5f Mon Sep 17 00:00:00 2001 From: Tunglies <77394545+Tunglies@users.noreply.github.com> Date: Sat, 13 Jun 2026 21:20:52 +0800 Subject: [PATCH] fix: keep home current proxy in sync --- src/components/home/current-proxy-card.tsx | 24 +--------------------- src/providers/app-data-provider.tsx | 4 +++- 2 files changed, 4 insertions(+), 24 deletions(-) diff --git a/src/components/home/current-proxy-card.tsx b/src/components/home/current-proxy-card.tsx index 3a28991c2..cfe31c837 100644 --- a/src/components/home/current-proxy-card.tsx +++ b/src/components/home/current-proxy-card.tsx @@ -439,27 +439,6 @@ export const CurrentProxyCard = () => { matchPolicyName, ]) - // 使用防抖包装状态更新 - const timeoutRef = React.useRef | null>(null) - - const debouncedSetState = useCallback( - (updateFn: (prev: ProxyState) => ProxyState) => { - if (timeoutRef.current) { - clearTimeout(timeoutRef.current) - } - timeoutRef.current = setTimeout(() => { - setState(updateFn) - }, 300) - }, - [setState], - ) - - useEffect(() => { - return () => { - if (timeoutRef.current) clearTimeout(timeoutRef.current) - } - }, []) - // 处理代理组变更 const handleGroupChange = useCallback( (event: SelectChangeEvent) => { @@ -504,7 +483,7 @@ export const CurrentProxyCard = () => { const currentGroup = state.selection.group const previousProxy = state.selection.proxy - debouncedSetState((prev: ProxyState) => ({ + setState((prev: ProxyState) => ({ ...prev, selection: { ...prev.selection, @@ -524,7 +503,6 @@ export const CurrentProxyCard = () => { isDirectMode, isGlobalMode, state.selection, - debouncedSetState, handleSelectChange, writeProfileScopedItem, ], diff --git a/src/providers/app-data-provider.tsx b/src/providers/app-data-provider.tsx index f2cdec6a2..d13633c4b 100644 --- a/src/providers/app-data-provider.tsx +++ b/src/providers/app-data-provider.tsx @@ -139,6 +139,8 @@ export const AppDataProvider = ({ lastProfileId = newProfileId lastUpdateTime = now void queryClient.invalidateQueries({ queryKey: ['getProfiles'] }) + refreshProxy().catch(() => {}) + refreshProxyProviders().catch(() => {}) refreshRules().catch(() => {}) refreshRuleProviders().catch(() => {}) } @@ -183,7 +185,7 @@ export const AppDataProvider = ({ } }) } - }, [refreshProxy, refreshRules, refreshRuleProviders]) + }, [refreshProxy, refreshProxyProviders, refreshRules, refreshRuleProviders]) const refreshAll = useCallback(async () => { await Promise.all([