Basic UI: fix refresh of hidden/visible image/chart #4534
Conversation
@resetnow : please confirm that I don't need anymore to provide the file smarthome.js in the web directory but only the one in the web-src directory ? If you can review, that would be cool. |
That's correct.
Later today. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would also check if the browser actually makes requests for images that are hidden with display: none;
.
_t.visible = state; | ||
}; | ||
|
||
_t.disactivateRefresh = function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You probably meant deactivateRefresh
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
_t.disactivateRefresh = function() { | ||
if (interval !== undefined) { | ||
clearInterval(interval); | ||
interval = undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JS type are weird but I think here null
is more suitable as it's used in the rest of the code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I will change that.
String url = chartUrl + "&t=" + (new Date()).getTime(); | ||
String url; | ||
if (!itemUIRegistry.getVisiblity(w)) { | ||
url = "images/none.png"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feels a bit weird here, should be a static const maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, why not.
interval = setInterval(function() { | ||
if (_t.image.clientWidth === 0) { | ||
clearInterval(interval); | ||
return; | ||
} | ||
_t.image.setAttribute("src", _t.url + "&t=" + Date.now()); | ||
if (_t.image.getAttribute("src").startsWith(_t.url)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't figure out what this is for.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is to avoid a refresh of the image using the proxied URL when the image was set with a raw data for example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I should rather set a variable to store the information whether we should refresh or not.
@resetnow : I have taken into account all your comments except one that remains to be considered. |
@resetnow : everything is now ok and working well. |
@resetnow If you can approve the changes, we should be good to merge! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This reverts commit d3301aa.
Fixes #4492
Fixes #4507
Ignore refresh when inappropriate
Signed-off-by: Laurent Garnier lg.hc@free.fr