extended forecast silent refresh

This commit is contained in:
Matt Walsh
2025-04-02 20:58:53 -05:00
parent 0baa31a92c
commit f7a15a93c6
4 changed files with 26 additions and 26 deletions

View File

@@ -22,9 +22,8 @@ class ExtendedForecast extends WeatherDisplay {
if (!super.getData(weatherParameters, refresh)) return;
// request us or si units
let forecast;
try {
forecast = await json(this.weatherParameters.forecast, {
this.data = await json(this.weatherParameters.forecast, {
data: {
units: settings.units.value,
},
@@ -34,11 +33,13 @@ class ExtendedForecast extends WeatherDisplay {
} catch (error) {
console.error('Unable to get extended forecast');
console.error(error.status, error.responseJSON);
this.setStatus(STATUS.failed);
return;
// if there's no previous data, fail
if (!this.data) {
this.setStatus(STATUS.failed);
return;
}
}
// we only get here if there was no error above
this.data = parse(forecast.properties.periods);
this.screenIndex = 0;
this.setStatus(STATUS.loaded);
}
@@ -48,7 +49,7 @@ class ExtendedForecast extends WeatherDisplay {
// determine bounds
// grab the first three or second set of three array elements
const forecast = this.data.slice(0 + 3 * this.screenIndex, 3 + this.screenIndex * 3);
const forecast = parse(this.data.properties.periods).slice(0 + 3 * this.screenIndex, 3 + this.screenIndex * 3);
// create each day template
const days = forecast.map((Day) => {