From 7943e8a1c376f571ace9c42fa69069b1cb7c7057 Mon Sep 17 00:00:00 2001 From: Josh Date: Tue, 1 Mar 2022 11:41:11 -0800 Subject: [PATCH] fix(explorer): retry should trigger loading state (#23417) * fix(explorer): retry should trigger loading state * fix(explorer): Solana ping add refreshing state --- .../providers/stats/SolanaPingProvider.tsx | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/explorer/src/providers/stats/SolanaPingProvider.tsx b/explorer/src/providers/stats/SolanaPingProvider.tsx index bed3505a0c..489904e4a4 100644 --- a/explorer/src/providers/stats/SolanaPingProvider.tsx +++ b/explorer/src/providers/stats/SolanaPingProvider.tsx @@ -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);