mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-11-08 11:02:08 +08:00
refactor(react): replace avoidable effects with derived state and handlers
Also drops a duplicate WebDAV history request on open and the per-keystroke DNS YAML dump.
This commit is contained in:
@@ -76,7 +76,7 @@ interface GroupSelectMenuProps {
|
||||
|
||||
interface ProxyGroupsChainProps {
|
||||
mode: string
|
||||
chainConfigData?: string | null
|
||||
chainConfigItems?: ProxyChainItem[] | null
|
||||
onExitChainMode: () => void
|
||||
availableGroups: any[]
|
||||
activeSelectedGroup: string | null
|
||||
@@ -305,7 +305,7 @@ export function ProxyGroupsChain(props: ProxyGroupsChainProps) {
|
||||
const { t } = useTranslation()
|
||||
const {
|
||||
mode,
|
||||
chainConfigData,
|
||||
chainConfigItems,
|
||||
onExitChainMode,
|
||||
availableGroups,
|
||||
activeSelectedGroup,
|
||||
@@ -338,6 +338,16 @@ export function ProxyGroupsChain(props: ProxyGroupsChainProps) {
|
||||
return []
|
||||
})
|
||||
|
||||
// Each fetched runtime chain replaces the stored one once.
|
||||
const configItems = chainConfigItems ?? null
|
||||
const [appliedConfigItems, setAppliedConfigItems] = useState<
|
||||
ProxyChainItem[] | null
|
||||
>(null)
|
||||
if (configItems !== appliedConfigItems) {
|
||||
setAppliedConfigItems(configItems)
|
||||
if (configItems?.length) setProxyChain(configItems)
|
||||
}
|
||||
|
||||
const candidateNodes = useMemo(
|
||||
() =>
|
||||
renderList.flatMap((item) => {
|
||||
@@ -520,7 +530,6 @@ export function ProxyGroupsChain(props: ProxyGroupsChainProps) {
|
||||
<ProxyChain
|
||||
proxyChain={currentProxyChain}
|
||||
onUpdateChain={setProxyChain}
|
||||
chainConfigData={chainConfigData}
|
||||
mode={mode}
|
||||
selectedGroup={activeSelectedGroup}
|
||||
onExitChainMode={onExitChainMode}
|
||||
|
||||
Reference in New Issue
Block a user