diff options
| author | Larvan2 <[email protected]> | 2023-06-07 14:45:51 +0800 |
|---|---|---|
| committer | Larvan2 <[email protected]> | 2023-06-07 14:47:20 +0800 |
| commit | d33452cf28edd071965090d5b18437c12f0e9ddb (patch) | |
| tree | ed484668780db17f7d77d8457878eb5526fee540 /src/components | |
| parent | 3ef02fa1dd220373124138e5aeaf9aa21a213e9f (diff) | |
fix: show delay for nested proxy-groups
Diffstat (limited to 'src/components')
| -rw-r--r-- | src/components/proxies/Proxy.tsx | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/components/proxies/Proxy.tsx b/src/components/proxies/Proxy.tsx index d319074..833d94b 100644 --- a/src/components/proxies/Proxy.tsx +++ b/src/components/proxies/Proxy.tsx @@ -82,10 +82,13 @@ function ProxySmallImpl({ isSelectable, onClick, }: ProxyProps) { + const delay = proxy.history[proxy.history.length - 1]?.delay; + const latencyNumber = latency?.number ?? delay; const color = useMemo( - () => getProxyDotBackgroundColor(latency, httpsLatencyTest), - [latency, proxy] + () => getProxyDotBackgroundColor({ number: latencyNumber }, httpsLatencyTest), + [latencyNumber] ); + const title = useMemo(() => { let ret = name; if (latency && typeof latency.number === 'number') { @@ -159,7 +162,13 @@ function ProxyImpl({ isSelectable, onClick, }: ProxyProps) { - const color = useMemo(() => getLabelColor(latency, httpsLatencyTest), [latency]); + const delay = proxy.history[proxy.history.length - 1]?.delay; + const latencyNumber = latency?.number ?? delay; + const color = useMemo( + () => getLabelColor({ number: latencyNumber }, httpsLatencyTest), + [latencyNumber] + ); + const doSelect = React.useCallback(() => { isSelectable && onClick && onClick(name); }, [name, onClick, isSelectable]); @@ -201,7 +210,7 @@ function ProxyImpl({ }); }, [isSelectable, now, latency]); - const latencyNumber = latency?.number ?? proxy.history[proxy.history.length - 1]?.delay; + // const latencyNumber = latency?.number ?? proxy.history[proxy.history.length - 1]?.delay; return ( <div @@ -242,8 +251,9 @@ const mapState = (s: any, { name }) => { const proxies = getProxies(s); const delay = getDelay(s); const latencyTestUrl = getLatencyTestUrl(s); + const proxy = proxies[name] || { name, history: [] }; return { - proxy: proxies[name], + proxy: proxy, latency: delay[name], httpsLatencyTest: latencyTestUrl.startsWith('https://'), }; |
