From 819c4cde1cbc54aba6e7a898b6bb39ba42a8151b Mon Sep 17 00:00:00 2001 From: vincep5 Date: Thu, 11 Jul 2019 12:49:24 -0500 Subject: [PATCH] Fix for weather module not refreshing data after exception --- CHANGELOG.md | 1 + modules/default/weather/providers/darksky.js | 6 ++++-- modules/default/weather/providers/openweathermap.js | 2 ++ modules/default/weather/providers/ukmetoffice.js | 2 ++ modules/default/weather/providers/weathergov.js | 2 ++ modules/default/weather/weatherprovider.js | 4 ---- 6 files changed, 11 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0cc229c749..bf7f4d32a8 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). ### Fixed - Updatenotification module: Properly handle race conditions, prevent crash. - 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 diff --git a/modules/default/weather/providers/darksky.js b/modules/default/weather/providers/darksky.js index 56d2e5bef8..b24c4794bc 100755 --- a/modules/default/weather/providers/darksky.js +++ b/modules/default/weather/providers/darksky.js @@ -32,7 +32,8 @@ WeatherProvider.register("darksky", { this.setCurrentWeather(currentWeather); }).catch(function(request) { Log.error("Could not load data ... ", request); - }); + }) + .finally(() => this.updateAvailable()) }, fetchWeatherForecast() { @@ -47,7 +48,8 @@ WeatherProvider.register("darksky", { this.setWeatherForecast(forecast); }).catch(function(request) { Log.error("Could not load data ... ", request); - }); + }) + .finally(() => this.updateAvailable()) }, // Create a URL from the config and base URL. diff --git a/modules/default/weather/providers/openweathermap.js b/modules/default/weather/providers/openweathermap.js index 60d82446ef..e99dc476c8 100755 --- a/modules/default/weather/providers/openweathermap.js +++ b/modules/default/weather/providers/openweathermap.js @@ -34,6 +34,7 @@ WeatherProvider.register("openweathermap", { .catch(function(request) { Log.error("Could not load data ... ", request); }) + .finally(() => this.updateAvailable()) }, // Overwrite the fetchCurrentWeather method. @@ -54,6 +55,7 @@ WeatherProvider.register("openweathermap", { .catch(function(request) { Log.error("Could not load data ... ", request); }) + .finally(() => this.updateAvailable()) }, /** OpenWeatherMap Specific Methods - These are not part of the default provider methods */ diff --git a/modules/default/weather/providers/ukmetoffice.js b/modules/default/weather/providers/ukmetoffice.js index 2dde2ddc03..47785b3b3a 100755 --- a/modules/default/weather/providers/ukmetoffice.js +++ b/modules/default/weather/providers/ukmetoffice.js @@ -41,6 +41,7 @@ WeatherProvider.register("ukmetoffice", { .catch(function(request) { Log.error("Could not load data ... ", request); }) + .finally(() => this.updateAvailable()) }, // Overwrite the fetchCurrentWeather method. @@ -62,6 +63,7 @@ WeatherProvider.register("ukmetoffice", { .catch(function(request) { Log.error("Could not load data ... ", request); }) + .finally(() => this.updateAvailable()) }, diff --git a/modules/default/weather/providers/weathergov.js b/modules/default/weather/providers/weathergov.js index bfecaf24be..74d9552217 100755 --- a/modules/default/weather/providers/weathergov.js +++ b/modules/default/weather/providers/weathergov.js @@ -35,6 +35,7 @@ WeatherProvider.register("weathergov", { .catch(function(request) { Log.error("Could not load data ... ", request); }) + .finally(() => this.updateAvailable()) }, // Overwrite the fetchCurrentWeather method. @@ -53,6 +54,7 @@ WeatherProvider.register("weathergov", { .catch(function(request) { Log.error("Could not load data ... ", request); }) + .finally(() => this.updateAvailable()) }, /** Weather.gov Specific Methods - These are not part of the default provider methods */ diff --git a/modules/default/weather/weatherprovider.js b/modules/default/weather/weatherprovider.js index 8940763aaf..1789b95caa 100644 --- a/modules/default/weather/weatherprovider.js +++ b/modules/default/weather/weatherprovider.js @@ -79,16 +79,12 @@ var WeatherProvider = Class.extend({ setCurrentWeather: function(currentWeatherObject) { // We should check here if we are passing a WeatherDay this.currentWeatherObject = currentWeatherObject; - - this.updateAvailable(); }, // Set the weatherForecastArray and notify the delegate that new information is available. setWeatherForecast: function(weatherForecastArray) { // We should check here if we are passing a WeatherDay this.weatherForecastArray = weatherForecastArray; - - this.updateAvailable(); }, // Set the fetched location name.