auto-retry for some forecast data

This commit is contained in:
Matt Walsh
2022-12-12 13:53:33 -06:00
parent 76fd93e6e1
commit 5dd8f4bd62
16 changed files with 101 additions and 36 deletions

View File

@@ -98,7 +98,7 @@ const getWeather = async (latLon) => {
const updateStatus = (value) => {
if (value.id < 0) return;
if (!progress) return;
progress.drawCanvas(displays, countLoadedCanvases());
progress.drawCanvas(displays, countLoadedDisplays());
// if this is the first display and we're playing, load it up so it starts playing
if (isPlaying() && value.id === 0 && value.status === STATUS.loaded) {
@@ -106,13 +106,16 @@ const updateStatus = (value) => {
}
// send loaded messaged to parent
if (countLoadedCanvases() < displays.length) return;
if (countLoadedDisplays() < displays.length) return;
// everything loaded, set timestamps
AssignLastUpdate(new Date());
};
const countLoadedCanvases = () => displays.reduce((acc, display) => {
// note: a display that is "still waiting"/"retrying" is considered loaded intentionally
// the weather.gov api has long load times for some products when you are the first
// requester for the product after the cache expires
const countLoadedDisplays = () => displays.reduce((acc, display) => {
if (display.status !== STATUS.loading) return acc + 1;
return acc;
}, 0);