lemmy-ui icon indicating copy to clipboard operation
lemmy-ui copied to clipboard

Add long polling to update unread counts in navbar.

Open dessalines opened this issue 2 years ago • 5 comments

Currently have this set to 30 seconds, either that or 1m seems good.

dessalines avatar Jun 14 '23 15:06 dessalines

I saw unread messages, reports, and applications getting polling. Is there one needed for replies as well?

SleeplessOne1917 avatar Jun 14 '23 15:06 SleeplessOne1917

unreadInboxCount includes unread replies, messages, and mentions.

dessalines avatar Jun 14 '23 16:06 dessalines

Sorry, I realized that I was commenting on #1148 when I meant to comment here 🤦 moving my comment:

Many users will have tens (in some cases even hundreds) of tabs open, so it could be extremely useful to either A) completely pause polling or B) just skip invoking the promiseFn in your poll function, whenever document.visibilityState != "visible"

For example with the 30 second polling:

If an instance has an average of 1000 users who leave 100 tabs open in the background, then not pausing background polling will generate 288 000 000 extra unnecessary http requests in a day (1000 users * 100 tabs * 2880 requests in a tab per 24h)

sunaurus avatar Jun 14 '23 16:06 sunaurus

@sunaurus I recall you linked a browser API that can be used to avoid this problem in the issue comments.

SleeplessOne1917 avatar Jun 14 '23 17:06 SleeplessOne1917

Yep, it's here: https://developer.mozilla.org/en-US/docs/Web/API/Document/visibilityState

sunaurus avatar Jun 14 '23 17:06 sunaurus