Skip to content

chore: add function to refetch latencies to ProxyContext #7769

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 1, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
rename
  • Loading branch information
Emyrk committed Jun 1, 2023
commit d75752912f328cf48693efe62cd6ba068d291311
11 changes: 6 additions & 5 deletions site/src/contexts/useProxyLatency.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,13 @@ export const useProxyLatency = (
{},
)

// This fetchNumber is used to trigger a refetch of the proxy latencies.
const [fetchNumber, setFetchNumber] = useState(0)
const refetch = (): void => {
setFetchNumber(fetchNumber + 1)
// This latestFetchRequest is used to trigger a refetch of the proxy latencies.
const [latestFetchRequest, setLatestFetchRequest] = useState(new Date().toISOString())
const refetch = () => {
setLatestFetchRequest(new Date().toISOString())
}


// Only run latency updates when the proxies change.
useEffect(() => {
if (!proxies) {
Expand Down Expand Up @@ -157,7 +158,7 @@ export const useProxyLatency = (
// via the performance observer. So we can disconnect the observer.
observer.disconnect()
})
}, [proxies, fetchNumber])
}, [proxies, latestFetchRequest])

return {
proxyLatencies,
Expand Down