Fix bug in ground, hazard and latest observation views where they could not be hidden

This commit is contained in:
mrkmntal 2026-08-21 13:13:43 -04:00
commit d120c27b6e
3 changed files with 8 additions and 11 deletions

View file

@ -12,12 +12,11 @@ class GroundView extends WeatherDisplay {
}
async getData(weatherParameters, refresh) {
const superResult = super.getData(weatherParameters, refresh);
this.setAutoReload();
if (!super.getData(weatherParameters, refresh)) return;
const requestToken = ++this.requestToken;
if (!this.weatherParameters?.latitude || !this.weatherParameters?.longitude || !this.weatherParameters?.city) {
this.setStatus(STATUS.noData);
return superResult;
return;
}
const url = new URL(withBasePath('api/ground-view'), window.location.origin);
@ -30,13 +29,13 @@ class GroundView extends WeatherDisplay {
});
if (requestToken !== this.requestToken) {
return superResult;
return;
}
if (!response?.success) {
this.data = null;
this.setStatus(STATUS.failed);
return superResult;
return;
}
this.data = {
@ -44,7 +43,6 @@ class GroundView extends WeatherDisplay {
hasWebcam: Boolean(response.webcam?.imageUrl),
};
this.setStatus(STATUS.loaded);
return superResult;
}
resetViewState() {

View file

@ -13,12 +13,12 @@ class HazardList extends WeatherDisplay {
}
async getData(weatherParameters, refresh) {
const superResult = super.getData(weatherParameters, refresh);
if (!super.getData(weatherParameters, refresh)) return;
await this.refreshHistoryNow();
return superResult;
}
async refreshHistoryNow() {
if (!this.isEnabled) return;
try {
// Fetch hazard history from backend
const response = await fetch(withBasePath('api/hazard-history'));

View file

@ -17,14 +17,13 @@ class LatestObservations extends WeatherDisplay {
}
async getData(weatherParameters, refresh) {
const superResult = super.getData(weatherParameters, refresh);
if (!super.getData(weatherParameters, refresh)) return;
this.data = await parseData(this.weatherParameters);
if (!this.data) {
this.setStatus(STATUS.failed);
return superResult;
return;
}
this.setStatus(STATUS.loaded);
return superResult;
}
async drawCanvas() {