Skip to content
This repository has been archived by the owner on May 7, 2020. It is now read-only.

Basic UI: fix refresh of hidden/visible image/chart #4534

Merged
merged 1 commit into from Nov 20, 2017
Merged

Basic UI: fix refresh of hidden/visible image/chart #4534

merged 1 commit into from Nov 20, 2017

Conversation

lolodomo
Copy link
Contributor

@lolodomo lolodomo commented Nov 12, 2017

Fixes #4492
Fixes #4507
Ignore refresh when inappropriate

Signed-off-by: Laurent Garnier lg.hc@free.fr

@lolodomo
Copy link
Contributor Author

@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.

@vlad-ivanov-name
Copy link
Contributor

I don't need anymore to provide the file smarthome.js in the web directory

That's correct.

If you can review, that would be cool.

Later today.

Copy link
Contributor

@vlad-ivanov-name vlad-ivanov-name left a 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() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You probably meant deactivateRefresh

Copy link
Contributor Author

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;
Copy link
Contributor

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

Copy link
Contributor Author

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";
Copy link
Contributor

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?

Copy link
Contributor Author

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)) {
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

@lolodomo
Copy link
Contributor Author

@resetnow : I have taken into account all your comments except one that remains to be considered.

Fixes #4492
Fixes #4507
Ignore refresh when inappropriate

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
@lolodomo
Copy link
Contributor Author

@resetnow : everything is now ok and working well.

@kaikreuzer
Copy link
Contributor

@resetnow If you can approve the changes, we should be good to merge!

Copy link
Contributor

@vlad-ivanov-name vlad-ivanov-name left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@maggu2810 maggu2810 merged commit d3301aa into eclipse-archived:master Nov 20, 2017
@lolodomo lolodomo deleted the hidden_chart branch November 20, 2017 10:49
kaikreuzer added a commit that referenced this pull request Nov 20, 2017
@kaikreuzer kaikreuzer added this to the 0.9.0 milestone Nov 30, 2017
@kaikreuzer kaikreuzer added the bug label Dec 15, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants