fix(explorer): retry should trigger loading state (#23417)

* fix(explorer): retry should trigger loading state

* fix(explorer): Solana ping add refreshing state
This commit is contained in:
Josh 2022-03-01 11:41:11 -08:00 committed by GitHub
parent 3e48cc4e00
commit 7943e8a1c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 5 deletions

View File

@ -33,6 +33,7 @@ export type PingInfo = {
export enum PingStatus {
Loading,
Refreshing,
Ready,
Error,
}
@ -124,15 +125,24 @@ export function SolanaPingProvider({ children }: Props) {
.catch((error) => {
setRollup({
status: PingStatus.Error,
retry: fetchPingMetrics,
retry: () => {
setRollup({
status: PingStatus.Loading,
});
fetchPingMetrics();
},
});
});
};
const fetchPingInterval = setInterval(
fetchPingMetrics,
FETCH_PING_INTERVAL
);
const fetchPingInterval = setInterval(() => {
setRollup({
status: PingStatus.Refreshing,
});
fetchPingMetrics();
}, FETCH_PING_INTERVAL);
fetchPingMetrics();
return () => {
clearInterval(fetchPingInterval);