Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9dbbe82

Browse files
fix(site): proxy menu not showing latency (coder#7785)
1 parent 9704945 commit 9dbbe82

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

site/src/components/Navbar/NavbarView.tsx

+6-7
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,11 @@ const ProxyMenu: FC<{ proxyContextValue: ProxyContextValue }> = ({
192192
const refreshLatencies = proxyContextValue.refetchProxyLatencies
193193
const closeMenu = () => setIsOpen(false)
194194
const navigate = useNavigate()
195+
const latencies = proxyContextValue.proxyLatencies
196+
const isLoadingLatencies = Object.keys(latencies).length === 0
197+
const isLoading = proxyContextValue.isLoading || isLoadingLatencies
195198

196-
if (!proxyContextValue.isFetched) {
199+
if (isLoading) {
197200
return (
198201
<Skeleton
199202
width="160px"
@@ -230,9 +233,7 @@ const ProxyMenu: FC<{ proxyContextValue: ProxyContextValue }> = ({
230233
{selectedProxy.display_name}
231234
<ProxyStatusLatency
232235
proxy={selectedProxy}
233-
latency={
234-
proxyContextValue.proxyLatencies?.[selectedProxy.id]?.latencyMS
235-
}
236+
latency={latencies?.[selectedProxy.id]?.latencyMS}
236237
/>
237238
</Box>
238239
) : (
@@ -278,9 +279,7 @@ const ProxyMenu: FC<{ proxyContextValue: ProxyContextValue }> = ({
278279
{proxy.display_name}
279280
<ProxyStatusLatency
280281
proxy={proxy}
281-
latency={
282-
proxyContextValue.proxyLatencies?.[proxy.id]?.latencyMS
283-
}
282+
latency={latencies?.[proxy.id]?.latencyMS}
284283
/>
285284
</Box>
286285
</MenuItem>

site/src/contexts/useProxyLatency.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@ const proxyLatenciesReducer = (
2424
state: Record<string, ProxyLatencyReport>,
2525
action: ProxyLatencyAction,
2626
): Record<string, ProxyLatencyReport> => {
27-
// Just overwrite any existing latency.
28-
state[action.proxyID] = action.report
29-
return state
27+
return {
28+
...state,
29+
[action.proxyID]: action.report,
30+
}
3031
}
3132

3233
export const useProxyLatency = (

0 commit comments

Comments
 (0)