Skip to content

Commit

Permalink
fix(explorer): retry should trigger loading state (solana-labs#23417)
Browse files Browse the repository at this point in the history
* fix(explorer): retry should trigger loading state

* fix(explorer): Solana ping add refreshing state
  • Loading branch information
oJshua authored Mar 1, 2022
1 parent 3e48cc4 commit 7943e8a
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions explorer/src/providers/stats/SolanaPingProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export type PingInfo = {

export enum PingStatus {
Loading,
Refreshing,
Ready,
Error,
}
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 7943e8a

Please sign in to comment.