vladimiry / ElectronMail

Unofficial ProtonMail Desktop App

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Improve getting unread emails count for Tutanota

vladimiry opened this issue · comments

Tutanota currently doesn't provide a convenient option to get unread count value not producing additional request to the server, but listening only. Hopefully it will be improved after the tutao/tutanota#234 and tutao/tutanota#229 issues resolving. I presume unread value will be provided by backend as a stream.

As for now, getting unread emails count in this app for Tutanota is done as Rest API polling, interval is 60 seconds. Checking of only the most 50 recent messages is happening and only in the inbox folder. So If there are unread messages, then it will be shown by app, but possible older unread messages or messages in other folders will not be taken into the account. Number 50 can be increased, but that will increase load on Tutanota Rest API.

Looks like app can listen for "instanceId": "someid", "operation":"1","type":"Mail" event batch action happening, then load a single/updated mail entity by instanceId and get unread state from it. It might also be possible to intercept related web client activity, as web client already subscribed to event batch stream. In that case there will be no need in polling requests. That would mean getting closer to a passive/listening mode - not producing addition requests to a server.

I'm considering to backup getting unread count feature by a local account cache, if such cache is enabled for the account, see details here. Since app can derive the unread count values from the database for free, for all the folders, with no emails scanning limit, and almost instantly.

Issue has been resolved with v2.0.0-beta.1.