Skip to content
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

Electron Wrapper #246

Open
exander77 opened this issue Nov 10, 2024 · 4 comments
Open

Electron Wrapper #246

exander77 opened this issue Nov 10, 2024 · 4 comments

Comments

@exander77
Copy link

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.

image

@exander77
Copy link
Author

I actually already have nice feature, that Alt+number switches between several mox accounts. I am really satisfied with it.

@mjl-
Copy link
Owner

mjl- commented Nov 13, 2024

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).

@exander77
Copy link
Author

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.

@mjl-
Copy link
Owner

mjl- commented Nov 16, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants