Skip to content

Commit

Permalink
Fix image info cache handling
Browse files Browse the repository at this point in the history
  • Loading branch information
j-a-n committed May 16, 2024
1 parent 1d4d7df commit 6ebebef
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions wallpanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -1616,6 +1616,9 @@ class WallpanelView extends HuiView {
}
val = date.toLocaleDateString(elHass.__hass.locale.language, options);
}
if (typeof val === 'object') {
val = JSON.stringify(val);
}
return prefix + val + suffix;
});
infoElement.innerHTML = html;
Expand Down Expand Up @@ -1778,7 +1781,7 @@ class WallpanelView extends HuiView {
http.send();
}

updateImageFromUrl(img, url) {
fillPlaceholders(url) {
let width = this.screensaverContainer.clientWidth;
let height = this.screensaverContainer.clientHeight;
let timestamp_ms = Date.now();
Expand All @@ -1787,12 +1790,20 @@ class WallpanelView extends HuiView {
url = url.replace(/\${height}/g, height);
url = url.replace(/\${timestamp_ms}/g, timestamp_ms);
url = url.replace(/\${timestamp}/g, timestamp);
img.imageUrl = url;
logger.debug(`Updating image '${img.id}' from '${url}'`);
return url;
}

updateImageFromUrl(img, url) {
const realUrl = this.fillPlaceholders(url);
if (realUrl != url && imageInfoCache[url]) {
imageInfoCache[realUrl] = imageInfoCache[url];
}
img.imageUrl = realUrl;
logger.debug(`Updating image '${img.id}' from '${realUrl}'`);
if (imageSourceType() == "media-entity") {
this.updateImageUrlWithHttpFetch(img, url);
this.updateImageUrlWithHttpFetch(img, realUrl);
} else {
img.src = url;
img.src = realUrl;
}
}

Expand Down

0 comments on commit 6ebebef

Please sign in to comment.