mirror of
https://github.com/netbymatt/ws4kp.git
synced 2026-04-22 03:29:31 -07:00
latest observations silent refresh
This commit is contained in:
@@ -29,6 +29,8 @@ class Hazards extends WeatherDisplay {
|
|||||||
async getData(weatherParameters, refresh) {
|
async getData(weatherParameters, refresh) {
|
||||||
// super checks for enabled
|
// super checks for enabled
|
||||||
const superResult = super.getData(weatherParameters, refresh);
|
const superResult = super.getData(weatherParameters, refresh);
|
||||||
|
// hazards performs a silent refresh, but does not fall back to a previous fetch if no data is available
|
||||||
|
// this is intentional to ensure the latest alerts only are displayed.
|
||||||
|
|
||||||
const alert = this.checkbox.querySelector('.alert');
|
const alert = this.checkbox.querySelector('.alert');
|
||||||
alert.classList.remove('show');
|
alert.classList.remove('show');
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ class HourlyGraph extends WeatherDisplay {
|
|||||||
this.elem.querySelector('.header .right').append(header);
|
this.elem.querySelector('.header .right').append(header);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getData(_weatherParameters, refresh) {
|
async getData(weatherParameters, refresh) {
|
||||||
if (!super.getData(undefined, refresh)) return;
|
if (!super.getData(undefined, refresh)) return;
|
||||||
|
|
||||||
const data = await getHourlyData(() => this.stillWaiting());
|
const data = await getHourlyData(() => this.stillWaiting());
|
||||||
|
|||||||
@@ -16,14 +16,15 @@ class LatestObservations extends WeatherDisplay {
|
|||||||
this.MaximumRegionalStations = 7;
|
this.MaximumRegionalStations = 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
async getData(_weatherParameters, refresh) {
|
async getData(weatherParameters, refresh) {
|
||||||
if (!super.getData(_weatherParameters, refresh)) return;
|
if (!super.getData(weatherParameters, refresh)) return;
|
||||||
const weatherParameters = _weatherParameters ?? this.weatherParameters;
|
// latest observations does a silent refresh but will not fall back to previously fetched data
|
||||||
|
// this is intentional because up to 30 stations are available to pull data from
|
||||||
|
|
||||||
// calculate distance to each station
|
// calculate distance to each station
|
||||||
const stationsByDistance = Object.keys(StationInfo).map((key) => {
|
const stationsByDistance = Object.keys(StationInfo).map((key) => {
|
||||||
const station = StationInfo[key];
|
const station = StationInfo[key];
|
||||||
const distance = calcDistance(station.lat, station.lon, weatherParameters.latitude, weatherParameters.longitude);
|
const distance = calcDistance(station.lat, station.lon, this.weatherParameters.latitude, this.weatherParameters.longitude);
|
||||||
return { ...station, distance };
|
return { ...station, distance };
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user