Better reentrancy guards for forecast.io.

The problem here is, that it fetches current and forecast data with one call.
merge-requests/218/head
Jens Lody 9 years ago
parent deb140b4c1
commit 0160a63ad0
  1. 10
      src/forecast_io.js

@ -105,7 +105,8 @@ function parseWeatherCurrent() {
return;
}
if (this.currentWeatherCache == "in refresh")
if ((this.forecastWeatherCache == "in refresh") ||
(this.currentWeatherCache == "in refresh"))
return;
this.checkPositionInPanel();
@ -209,6 +210,10 @@ function refreshWeatherCurrent() {
}
function parseWeatherForecast() {
if ((this.forecastWeatherCache == "in refresh") ||
(this.currentWeatherCache == "in refresh"))
return;
if (this.forecastWeatherCache === undefined) {
// this is a reentrency guard, in this times set for both caches,
// because they get updated with one call to forecast.io
@ -222,9 +227,6 @@ function parseWeatherForecast() {
return;
}
if (this.forecastWeatherCache == "in refresh")
return;
let forecast = this.forecastWeatherCache;
let beginOfDay = new Date(new Date().setHours(0, 0, 0, 0));
let cnt = Math.min(this._days_forecast, forecast.length);

Loading…
Cancel
Save