-
Notifications
You must be signed in to change notification settings - Fork 152
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
Show notification on new changes to pre-empt edit conflicts #1967
base: master
Are you sure you want to change the base?
Conversation
Polls the API every 5 seconds to check if there are new revisions or if the page has been deleted. Solves #1418.
clearInterval(interval); | ||
} | ||
}); | ||
}, 5000); |
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.
Will this run every 5 seconds that the page is open, indefinitely?
If the page loses focus, does this still run?
If so, this could really hammer the servers. Sometimes I'll keep dozens of tabs open overnight. If needed, we should consider writing a back-off algorithm. For example, change the check rate to every hour after the first 5 minutes. Or only run when the tab is focused.
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.
@siddharthvp , any thoughts on this one? I want to clear the PR queue this week :)
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.
Hmm, on second thought, this would probably only do the 5 second check when that particular Morebits window is open, which is pretty rare. Not as big a problem as I was thinking.
A backoff alg might not be a bad idea though, since hammering the servers every 5 seconds for hours would probably not be ideal.
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.
This needs to be updated to stop polling once the Twinkle dialog has been closed. And we can include a document.hasFocus() check as well. I'll likely be able to get to this only next week :(
I think adding backoff is overcomplicating things, as people are presumably not going to keep Twinkle open for hours. Even if a few folks do, 1 read request every 5 seconds is nothing – the servers can handle a lot more than that. Besides, most browsers tend to throttle or suspend JS execution in inactive tabs.
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.
1 read request every 5 seconds is nothing – the servers can handle a lot more than that.
Some pages like watchlist and RecentChanges in core already do this kind of polling. So does DiscussionTools I think to show new comments on talk page? (not sure about DT as I use CD instead - which also does it btw).
Solves #1418.