Skip to content
Merged
Changes from all commits
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
20 changes: 17 additions & 3 deletions apps/nowcasting-app/components/map/pvLatestMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -497,13 +497,27 @@ const PvLatestMap: React.FC<PvLatestMapProps> = ({
};
}, [mapDataLoading]);

// Debounce the spinner so it only shows for data loads, not the brief
// mapDataLoading rerender that happens when flipping between already-cached
// timesteps. If loading resolves within the threshold (cached re-render),
// the spinner never appears.
const isLoading =
!combinedData.allGspForecastData || combinedLoading.allGspForecastLoading || mapDataLoading;
const [showSpinner, setShowSpinner] = useState(false);
useEffect(() => {
if (!isLoading) {
setShowSpinner(false);
return;
}
const t = setTimeout(() => setShowSpinner(true), 700);
return () => clearTimeout(t);
}, [isLoading]);

return (
<div className={`pv-map relative h-full w-full ${className}`}>
{
<>
{(!combinedData.allGspForecastData ||
combinedLoading.allGspForecastLoading ||
mapDataLoading) && (
{showSpinner && (
<LoadStateMap>
<Spinner />
</LoadStateMap>
Expand Down
Loading