Open exander77 opened 1 week ago
I actually already have nice feature, that Alt+number switches between several mox accounts. I am really satisfied with it.
Interesting! Would it be enough if the JS code called some special JS function (that you provide) when a new message comes in? Changes to the mailboxes/messages are coming in over an SSE connection, with handler functions in JS that update the UI. We could add some calls to that (conditional on them being defined, which would only be the case for an electron app).
Interesting! Would it be enough if the JS code called some special JS function (that you provide) when a new message comes in? Changes to the mailboxes/messages are coming in over an SSE connection, with handler functions in JS that update the UI. We could add some calls to that (conditional on them being defined, which would only be the case for an electron app).
Yes, Electron can inject API, usually on window
element. But mox could also issue standard notification, I worked with this on Protonmail. That way doesn't depend on any knowledge of the environment.
The standard notifications are these, right? https://developer.mozilla.org/en-US/docs/Web/API/Notifications_API
I was thinking of calling some electron-provided code to the current webmail code to keep it consistent with what you're seeing in the webmail ui. If unread messages are retrieved from an API call, I'm assuming you're going to periodically call it, not on every interaction the user has in webmail, eg reading a message and marking it unread. I expect that would result in somewhat delayed updating of the unread count shown with the app icon. The webmail already shows unread messages next to a mailbox, it shouldn't be too hard to call an extra function whenever that is rendered/changed.
If you're doing api calls outside the regular webmail code, you'll also run into authentication: You would need to grab auth tokens from webmail (localstorage, httponly cookie (may not be possible?)).
Or are you looking for a way to register some code that runs independently of whether the electron is started? So that you can get a message count even when the app isn't fully running?
About notifications, would you want them only for new messages in the Inbox? Or also in other mailboxes (all, specifically configured ones)?
I want to also add a little unread message counter to the favicon. I currently have my webmail open in a pinned firefox tab. It will show a dot below the favicon when something in the DOM changed. It's been serving as a poor mans "new message" indicator, but also triggers for messages in other mailboxes (mailing lists), which makes is less useful. Updating the favicon unread message count will probably be updated at the same time you're looking to update an app icon unread message count.
I wrapped the web interface Electron for my personal use, but maybe it could be good to make an app for everybody.
I would need just minor support API, if mox had an endpoint for number of unread messages and issued notification on each message received, I could make it into a nice app that shows number of unread mails in a tray.