Fix for weather module not refreshing data after exception

This commit is contained in:
vincep5 2019-07-11 12:49:24 -05:00
parent 776c486b1a
commit 819c4cde1c
6 changed files with 11 additions and 6 deletions

View File

@ -19,6 +19,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
### Fixed ### Fixed
- Updatenotification module: Properly handle race conditions, prevent crash. - Updatenotification module: Properly handle race conditions, prevent crash.
- Send `NEWS_FEED` notification also for the first news messages which are shown - Send `NEWS_FEED` notification also for the first news messages which are shown
- Fixed issue where weather module would not refresh data after a network or API outage [#1722](https://github.com/MichMich/MagicMirror/issues/1722)
## [2.8.0] - 2019-07-01 ## [2.8.0] - 2019-07-01

View File

@ -32,7 +32,8 @@ WeatherProvider.register("darksky", {
this.setCurrentWeather(currentWeather); this.setCurrentWeather(currentWeather);
}).catch(function(request) { }).catch(function(request) {
Log.error("Could not load data ... ", request); Log.error("Could not load data ... ", request);
}); })
.finally(() => this.updateAvailable())
}, },
fetchWeatherForecast() { fetchWeatherForecast() {
@ -47,7 +48,8 @@ WeatherProvider.register("darksky", {
this.setWeatherForecast(forecast); this.setWeatherForecast(forecast);
}).catch(function(request) { }).catch(function(request) {
Log.error("Could not load data ... ", request); Log.error("Could not load data ... ", request);
}); })
.finally(() => this.updateAvailable())
}, },
// Create a URL from the config and base URL. // Create a URL from the config and base URL.

View File

@ -34,6 +34,7 @@ WeatherProvider.register("openweathermap", {
.catch(function(request) { .catch(function(request) {
Log.error("Could not load data ... ", request); Log.error("Could not load data ... ", request);
}) })
.finally(() => this.updateAvailable())
}, },
// Overwrite the fetchCurrentWeather method. // Overwrite the fetchCurrentWeather method.
@ -54,6 +55,7 @@ WeatherProvider.register("openweathermap", {
.catch(function(request) { .catch(function(request) {
Log.error("Could not load data ... ", request); Log.error("Could not load data ... ", request);
}) })
.finally(() => this.updateAvailable())
}, },
/** OpenWeatherMap Specific Methods - These are not part of the default provider methods */ /** OpenWeatherMap Specific Methods - These are not part of the default provider methods */

View File

@ -41,6 +41,7 @@ WeatherProvider.register("ukmetoffice", {
.catch(function(request) { .catch(function(request) {
Log.error("Could not load data ... ", request); Log.error("Could not load data ... ", request);
}) })
.finally(() => this.updateAvailable())
}, },
// Overwrite the fetchCurrentWeather method. // Overwrite the fetchCurrentWeather method.
@ -62,6 +63,7 @@ WeatherProvider.register("ukmetoffice", {
.catch(function(request) { .catch(function(request) {
Log.error("Could not load data ... ", request); Log.error("Could not load data ... ", request);
}) })
.finally(() => this.updateAvailable())
}, },

View File

@ -35,6 +35,7 @@ WeatherProvider.register("weathergov", {
.catch(function(request) { .catch(function(request) {
Log.error("Could not load data ... ", request); Log.error("Could not load data ... ", request);
}) })
.finally(() => this.updateAvailable())
}, },
// Overwrite the fetchCurrentWeather method. // Overwrite the fetchCurrentWeather method.
@ -53,6 +54,7 @@ WeatherProvider.register("weathergov", {
.catch(function(request) { .catch(function(request) {
Log.error("Could not load data ... ", request); Log.error("Could not load data ... ", request);
}) })
.finally(() => this.updateAvailable())
}, },
/** Weather.gov Specific Methods - These are not part of the default provider methods */ /** Weather.gov Specific Methods - These are not part of the default provider methods */

View File

@ -79,16 +79,12 @@ var WeatherProvider = Class.extend({
setCurrentWeather: function(currentWeatherObject) { setCurrentWeather: function(currentWeatherObject) {
// We should check here if we are passing a WeatherDay // We should check here if we are passing a WeatherDay
this.currentWeatherObject = currentWeatherObject; this.currentWeatherObject = currentWeatherObject;
this.updateAvailable();
}, },
// Set the weatherForecastArray and notify the delegate that new information is available. // Set the weatherForecastArray and notify the delegate that new information is available.
setWeatherForecast: function(weatherForecastArray) { setWeatherForecast: function(weatherForecastArray) {
// We should check here if we are passing a WeatherDay // We should check here if we are passing a WeatherDay
this.weatherForecastArray = weatherForecastArray; this.weatherForecastArray = weatherForecastArray;
this.updateAvailable();
}, },
// Set the fetched location name. // Set the fetched location name.