Invalidate data, if the physical network connection exists, but the server can not be reached or does not send data.

multiprovider
Jens Lody 11 years ago
parent 8bb7406ba9
commit cec89bce08
  1. 20
      src/extension.js

@ -350,8 +350,6 @@ const WeatherMenuButton = new Lang.Class({
if (this.locationChanged()) { if (this.locationChanged()) {
this.currentWeatherCache = undefined; this.currentWeatherCache = undefined;
this.forecastWeatherCache = undefined; this.forecastWeatherCache = undefined;
this.rebuildCurrentWeatherUi();
this.rebuildFutureWeatherUi();
} }
this.parseWeatherCurrent(); this.parseWeatherCurrent();
})); }));
@ -1139,12 +1137,12 @@ weather-storm.png = weather-storm-symbolic.svg
let message = Soup.form_request_new_from_hash('GET', url, params); let message = Soup.form_request_new_from_hash('GET', url, params);
_httpSession.queue_message(message, Lang.bind(this, function(_httpSession, message) { _httpSession.queue_message(message, Lang.bind(this, function(_httpSession, message) {
try {
if (!message.response_body.data) { if (!message.response_body.data) {
fun.call(this, 0); fun.call(this, 0);
return; return;
} }
try {
let jp = JSON.parse(message.response_body.data); let jp = JSON.parse(message.response_body.data);
fun.call(this, jp); fun.call(this, jp);
} catch (e) { } catch (e) {
@ -1414,8 +1412,13 @@ weather-storm.png = weather-storm-symbolic.svg
this.rebuildSelectCityItem(); this.rebuildSelectCityItem();
this.parseWeatherCurrent(); this.parseWeatherCurrent();
} else } else {
// we are connected, but get no (or no correct) data, so invalidate
// the shown data and reload after 10 minutes (recommendded by openweathermap.org)
// this.currentWeatherCache = undefined;
this.rebuildCurrentWeatherUi();
this.reloadWeatherCurrent(600); this.reloadWeatherCurrent(600);
}
}); });
this.reloadWeatherCurrent(this._refresh_interval_current); this.reloadWeatherCurrent(this._refresh_interval_current);
}, },
@ -1542,8 +1545,13 @@ weather-storm.png = weather-storm-symbolic.svg
this.forecastWeatherCache = json.list; this.forecastWeatherCache = json.list;
this.parseWeatherForecast(); this.parseWeatherForecast();
} else } else {
// we are connected, but get no (or no correct) data, so invalidate
// the shown data and reload after 10 minutes (recommendded by openweathermap.org)
// this.forecastWeatherCache = undefined;
this.rebuildFutureWeatherUi();
this.reloadWeatherForecast(600); this.reloadWeatherForecast(600);
}
}); });
this.reloadWeatherForecast(this._refresh_interval_forecast); this.reloadWeatherForecast(this._refresh_interval_forecast);
}, },

Loading…
Cancel
Save