mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-29 08:45:41 +08:00
feat: optimize delay checker concurrency strategy
This commit is contained in:
@@ -70,12 +70,9 @@ const ProxyGlobal = (props: Props) => {
|
||||
const onCheckAll = useLockFn(async () => {
|
||||
const names = sortedProxies.map((p) => p.name);
|
||||
|
||||
await delayManager.checkListDelay(
|
||||
{ names, groupName, skipNum: 8, maxTimeout: 600 },
|
||||
() => mutate("getProxies")
|
||||
await delayManager.checkListDelay({ names, groupName, skipNum: 8 }, () =>
|
||||
mutate("getProxies")
|
||||
);
|
||||
|
||||
mutate("getProxies");
|
||||
});
|
||||
|
||||
useEffect(() => onLocation(false), [groupName]);
|
||||
|
||||
@@ -92,12 +92,11 @@ const ProxyGroup = ({ group }: Props) => {
|
||||
const names = sortedProxies.map((p) => p.name);
|
||||
const groupName = group.name;
|
||||
|
||||
await delayManager.checkListDelay(
|
||||
{ names, groupName, skipNum: 8, maxTimeout: 600 },
|
||||
() => mutate("getProxies")
|
||||
await delayManager.checkListDelay({ names, groupName, skipNum: 8 }, () =>
|
||||
mutate("getProxies")
|
||||
);
|
||||
|
||||
mutate("getProxies");
|
||||
console.log("finish");
|
||||
});
|
||||
|
||||
// auto scroll to current index
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { useEffect, useState } from "react";
|
||||
import { useLockFn } from "ahooks";
|
||||
import { CheckCircleOutlineRounded } from "@mui/icons-material";
|
||||
import {
|
||||
alpha,
|
||||
@@ -50,20 +51,15 @@ const ProxyItem = (props: Props) => {
|
||||
}
|
||||
}, [proxy]);
|
||||
|
||||
const delayRef = useRef(false);
|
||||
const onDelay = (e: any) => {
|
||||
const onDelay = useLockFn(async (e: any) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
if (delayRef.current) return;
|
||||
delayRef.current = true;
|
||||
|
||||
delayManager
|
||||
return delayManager
|
||||
.checkDelay(proxy.name, groupName)
|
||||
.then((result) => setDelay(result))
|
||||
.catch(() => setDelay(1e6))
|
||||
.finally(() => (delayRef.current = false));
|
||||
};
|
||||
.catch(() => setDelay(1e6));
|
||||
});
|
||||
|
||||
return (
|
||||
<ListItem sx={sx}>
|
||||
|
||||
Reference in New Issue
Block a user