-
Notifications
You must be signed in to change notification settings - Fork 887
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
Conversation
site/src/contexts/useProxyLatency.ts
Outdated
// This fetchNumber is used to trigger a refetch of the proxy latencies. | ||
const [fetchNumber, setFetchNumber] = useState(0) | ||
const refetch = (): void => { | ||
setFetchNumber(fetchNumber + 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this name is ok, but I would do something like this:
const [latestFetchRequest, setLatestFetchRequest] = useState(new Date().toISOString())
const refetch = () => {
setLatestFetchRequest(new Date().toISOString())
}
I think this is a bit better because we can display the latest time the latency was checked if we want to and the naming is easier to reason about but it is up to you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Each latency report has the date it was checked. I was thinking about adding an integer counter so the FE can tell if the latency provided is the latest one requested. But I figured if we want to add UI flair, we can implement it then.
I will update the name, and make it a date, but won't do anything with the date for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one minor suggestion.
The button when clicked is async, so maybe we need to add some sort of loading wheel or something?