From 8660a11c2b39cf03f3cb2b1df00f7ae04b11f403 Mon Sep 17 00:00:00 2001 From: Tunglies <77394545+Tunglies@users.noreply.github.com> Date: Mon, 9 Nov 2026 13:06:07 +0800 Subject: [PATCH] fix(proxy): preserve rapid group selections Refs: #8602 Refs: 262b6f8adfd862c42d954383dca33f9a68e8451a --- src/hooks/use-proxy-selection.ts | 29 ++++------------------------- 1 file changed, 4 insertions(+), 25 deletions(-) diff --git a/src/hooks/use-proxy-selection.ts b/src/hooks/use-proxy-selection.ts index d773ef361..ded16c051 100644 --- a/src/hooks/use-proxy-selection.ts +++ b/src/hooks/use-proxy-selection.ts @@ -1,4 +1,4 @@ -import { useCallback, useRef } from 'react' +import { useCallback } from 'react' import { closeConnection, getConnections, @@ -49,8 +49,6 @@ export const useProxySelection = (options: ProxySelectionOptions = {}) => { const recordSelection = useRecordSelection() const forgetSelection = useForgetSelection() const { verge } = useVerge() - const pendingRequestRef = useRef(null) - const isProcessingRef = useRef(false) const { onSuccess, onError } = options @@ -118,24 +116,6 @@ export const useProxySelection = (options: ProxySelectionOptions = {}) => { ], ) - const flushChangeQueue = useCallback(async () => { - if (isProcessingRef.current) return - isProcessingRef.current = true - - try { - while (pendingRequestRef.current) { - const request = pendingRequestRef.current - pendingRequestRef.current = null - await executeChange(request) - } - } finally { - isProcessingRef.current = false - if (pendingRequestRef.current) { - void flushChangeQueue() - } - } - }, [executeChange]) - const select = useCallback( ( groupName: string, @@ -143,15 +123,14 @@ export const useProxySelection = (options: ProxySelectionOptions = {}) => { previousProxy?: string, fixed?: string, ) => { - pendingRequestRef.current = { + void executeChange({ groupName, proxyName, previousProxy, fixed, - } - void flushChangeQueue() + }) }, - [flushChangeQueue], + [executeChange], ) return { select }