Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avoid periodic polls when document doesn't have focus #3931

Merged
merged 2 commits into from Feb 23, 2018

Conversation

@minrk
Copy link
Contributor

@minrk minrk commented Feb 21, 2018

avoids constantly pinging servers when the tab is in the background

This is all of the unconditional polls I could find

solves part of #3929

avoids constantly pinging servers when the tab is in the background
Copy link
Member

@afshin afshin left a comment

Thanks! This is a good idea.

@afshin
Copy link
Member

@afshin afshin commented Feb 21, 2018

Hm. Actually I think what we want is to check document.hidden and not document.hasFocus().

https://developer.mozilla.org/en-US/docs/Web/API/Document/hasFocus
vs.
https://developer.mozilla.org/en-US/docs/Web/API/Document/hidden

Because if the window doesn't have focus but the user is still looking at it (say it's on another screen and you've switched to some other app) it should still make those requests, but if it is in a background tab, it shouldn't.

@minrk If you disagree with the change I pushed to this branch, feel free to hard reset to your commit!

@afshin afshin dismissed their stale review Feb 21, 2018

(I materially changed the code from the original PR.)

@minrk
Copy link
Contributor Author

@minrk minrk commented Feb 21, 2018

👍 makes sense!

@afshin afshin merged commit fbb2dec into jupyterlab:master Feb 23, 2018
2 checks passed
@ellisonbg
Copy link
Contributor

@ellisonbg ellisonbg commented Feb 24, 2018

@minrk minrk deleted the checkFocus branch Feb 26, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Aug 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants