add refresh flag to getdata funcions
This commit is contained in:
parent
b272aa298a
commit
23cc1a1f7a
14 changed files with 34 additions and 18 deletions
|
|
@ -22,6 +22,7 @@ class WeatherDisplay {
|
|||
this.okToDrawCurrentConditions = true;
|
||||
this.okToDrawCurrentDateTime = true;
|
||||
this.showOnProgress = true;
|
||||
this.autoRefreshHandle = null;
|
||||
|
||||
// default navigation timing
|
||||
this.timing = {
|
||||
|
|
@ -129,9 +130,14 @@ class WeatherDisplay {
|
|||
}
|
||||
|
||||
// get necessary data for this display
|
||||
getData(weatherParameters) {
|
||||
// clear current data
|
||||
this.data = undefined;
|
||||
getData(weatherParameters, refresh) {
|
||||
// refresh doesn't delete existing data, and is resued if the silent refresh fails
|
||||
if (!refresh) {
|
||||
this.data = undefined;
|
||||
}
|
||||
// clear any refresh timers
|
||||
clearTimeout(this.autoRefreshHandle);
|
||||
this.autoRefreshHandle = null;
|
||||
|
||||
// store weatherParameters locally in case we need them later
|
||||
if (weatherParameters) this.weatherParameters = weatherParameters;
|
||||
|
|
@ -144,6 +150,9 @@ class WeatherDisplay {
|
|||
return false;
|
||||
}
|
||||
|
||||
// set up auto reload
|
||||
this.autoRefreshHandle = setTimeout(() => this.getData(false, true), settings.refreshTime.value);
|
||||
|
||||
// recalculate navigation timing (in case it was modified in the constructor)
|
||||
this.calcNavTiming();
|
||||
return true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue