Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions site/src/components/Navbar/NavbarView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,11 @@ const ProxyMenu: FC<{ proxyContextValue: ProxyContextValue }> = ({
const refreshLatencies = proxyContextValue.refetchProxyLatencies
const closeMenu = () => setIsOpen(false)
const navigate = useNavigate()
const latencies = proxyContextValue.proxyLatencies
const isLoadingLatencies = Object.keys(latencies).length === 0
const isLoading = proxyContextValue.isLoading || isLoadingLatencies

if (!proxyContextValue.isFetched) {
if (isLoading) {
return (
<Skeleton
width="160px"
Expand Down Expand Up @@ -230,9 +233,7 @@ const ProxyMenu: FC<{ proxyContextValue: ProxyContextValue }> = ({
{selectedProxy.display_name}
<ProxyStatusLatency
proxy={selectedProxy}
latency={
proxyContextValue.proxyLatencies?.[selectedProxy.id]?.latencyMS
}
latency={latencies?.[selectedProxy.id]?.latencyMS}
/>
</Box>
) : (
Expand Down Expand Up @@ -278,9 +279,7 @@ const ProxyMenu: FC<{ proxyContextValue: ProxyContextValue }> = ({
{proxy.display_name}
<ProxyStatusLatency
proxy={proxy}
latency={
proxyContextValue.proxyLatencies?.[proxy.id]?.latencyMS
}
latency={latencies?.[proxy.id]?.latencyMS}
/>
</Box>
</MenuItem>
Expand Down
7 changes: 4 additions & 3 deletions site/src/contexts/useProxyLatency.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ const proxyLatenciesReducer = (
state: Record<string, ProxyLatencyReport>,
action: ProxyLatencyAction,
): Record<string, ProxyLatencyReport> => {
// Just overwrite any existing latency.
state[action.proxyID] = action.report
return state
return {
...state,
[action.proxyID]: action.report,
}
}

export const useProxyLatency = (
Expand Down