diff --git a/src/components/proxies/ProxyLatency.tsx b/src/components/proxies/ProxyLatency.tsx
index 29036d5..a617a62 100644
--- a/src/components/proxies/ProxyLatency.tsx
+++ b/src/components/proxies/ProxyLatency.tsx
@@ -3,14 +3,14 @@ import * as React from 'react';
import s0 from './ProxyLatency.module.scss';
type ProxyLatencyProps = {
- number?: number;
+ number?: any;
color: string;
};
export function ProxyLatency({ number, color }: ProxyLatencyProps) {
return (
- {typeof number === 'number' && number !== 0 ? number + ' ms' : ' '}
+ {typeof number === 'number' ? (number !== 0 ? number + ' ms' : ' ') : number}
);
}
diff --git a/src/store/proxies.tsx b/src/store/proxies.tsx
index 5f4c0aa..e7b4f61 100644
--- a/src/store/proxies.tsx
+++ b/src/store/proxies.tsx
@@ -270,12 +270,13 @@ function requestDelayForProxyOnce(apiConfig: ClashAPIConfig, name: string) {
return async (dispatch: DispatchFn, getState: GetStateFn) => {
const latencyTestUrl = getLatencyTestUrl(getState());
const res = await proxiesAPI.requestDelayForProxy(apiConfig, name, latencyTestUrl);
- let error = '';
+
if (res.ok === false) {
- error = res.statusText;
+ var delay: any = res.statusText;
+ } else {
+ var { delay } = await res.json();
}
- const { delay } = await res.json();
- const delayNext = { ...getDelay(getState()), [name]: { error, number: delay } };
+ const delayNext = { ...getDelay(getState()), [name]: { number: delay } };
dispatch('requestDelayForProxyOnce', (s) => {
s.proxies.delay = delayNext;
@@ -291,33 +292,19 @@ export function requestDelayForProxy(apiConfig: ClashAPIConfig, name: string) {
export function requestDelayForProxies(apiConfig: ClashAPIConfig, names: string[]) {
return async (dispatch: DispatchFn, getState: GetStateFn) => {
- const proxies = getProxies(getState());
- const latencyTestUrl = getLatencyTestUrl(getState());
- const proxyDedupMap = new Map();
- const providerDedupMap = new Map();
+ let delayClear = getDelay(getState())
- const works = names.map((name) => {
- const p = proxies[name];
- if (!p.__provider) {
- if (proxyDedupMap.get(name)) {
- return undefined;
- } else {
- proxyDedupMap.set(name, true);
- return proxiesAPI.requestDelayForProxy(apiConfig, name, latencyTestUrl);
- }
- } else if (p.__provider) {
- // this one is from a proxy provider
- if (providerDedupMap.get(p.__provider)) {
- return undefined;
- } else {
- providerDedupMap.set(p.__provider, true);
- return healthcheckProviderByNameInternal(apiConfig, p.__provider);
- }
- } else {
- return undefined;
- }
+ for (var name of names) {
+ delayClear[name] = { number: "- ms" }
+ }
+
+ dispatch('clearDelayBeforeTest', (s) => {
+ s.proxies.delay = delayClear;
});
+
+ const works = names.map((name) => requestDelayForProxy(apiConfig, name)(dispatch))
+
await Promise.all(works);
await dispatch(fetchProxies(apiConfig));
};
diff --git a/src/store/types.ts b/src/store/types.ts
index b0b457e..70b97db 100644
--- a/src/store/types.ts
+++ b/src/store/types.ts
@@ -41,7 +41,7 @@ export type ProxyItem = {
};
export type ProxyDelayItem = {
- number?: number;
+ number?: any;
};
export type ProxiesMapping = Record;