mirror of
https://github.com/netbymatt/ws4kp.git
synced 2026-04-18 17:49:31 -07:00
add refresh flag to getdata funcions
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user