Open mvl22 opened 4 years ago
So you'd like the thread page to poll for new messages? I'm a bit afraid this might spam us. I would prefer to use websockets but that is probably over-engineering. Is polling once every 30s enough, slowing to once every 2 mins or so after the page has been open for over 10 mins, with polling stopping if the user changes tab?
So you'd like the thread page to poll for new messages? I'm a bit afraid this might spam us. I would prefer to use websockets but that is probably over-engineering. Is polling once every 30s enough, slowing to once every 2 mins or so after the page has been open for over 10 mins,
Yes, that would easily be enough.
Websockets definitely feels like over-engineering, and in general I'm not a fan of that stuff. A simple AJAX call should be sufficient.
with polling stopping if the user changes tab?
But it should return if the user puts the tab active again.
I see there is a Page Visibility API which is well-supported: https://www.html5rocks.com/en/tutorials/pagevisibility/intro/ https://caniuse.com/#feat=pagevisibility
I think the logic is:
If you are on a page, writing a post, and another message comes in, you don't know about it.
The page should do AJAX requests to check for new posts, and push them into the page, with a flash. The browser will probably auto scroll.
I imagine this could use a similar mechanism to the AJAX loading of a message just posted.