Check for undefined header data in weather modules

This commit is contained in:
rejas
2020-08-01 12:30:59 +02:00
parent 5aa7097a6e
commit 86fb1b938b
3 changed files with 15 additions and 10 deletions

View File

@@ -37,6 +37,8 @@ Module.register("currentweather", {
weatherEndpoint: "weather",
appendLocationNameToHeader: true,
useLocationAsHeader: false,
calendarClass: "calendar",
tableClass: "large",
@@ -267,15 +269,16 @@ Module.register("currentweather", {
// Override getHeader method.
getHeader: function () {
if (this.config.appendLocationNameToHeader && this.data.header !== undefined) {
return this.data.header + " " + this.fetchedLocationName;
}
if (this.config.useLocationAsHeader && this.config.location !== false) {
return this.config.location;
}
return this.data.header;
if (this.config.appendLocationNameToHeader) {
if (this.data.header) return this.data.header + " " + this.fetchedLocationName;
else return this.fetchedLocationName;
}
return this.data.header ? this.data.header : "";
},
// Override notification handler.