Skip to content

Commit

Permalink
fix: proton mail scheduled emails are shown in unread message badge (#…
Browse files Browse the repository at this point in the history
…530)

- narrow down selector to grab counter from "inbox" entry
  • Loading branch information
mcmxcdev authored Apr 13, 2024
1 parent 099f029 commit 0337750
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions recipes/proton-mail/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "proton-mail",
"name": "ProtonMail",
"version": "1.7.0",
"name": "Proton Mail",
"version": "1.7.1",
"license": "MIT",
"config": {
"serviceURL": "https://mail.proton.me/login"
Expand Down
4 changes: 2 additions & 2 deletions recipes/proton-mail/webview.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ const _path = _interopRequireDefault(require('path'));
module.exports = Ferdium => {
const getMessages = () => {
let unreadCount = 0;
// Loop over all displayed counters and take the highest one (from the "All Mail" folder)
// Take the counter element from the "Inbox" folder
for (const counterElement of document.querySelectorAll(
'.navigation-counter-item',
'[data-testid="navigation-link:inbox"] [data-testid="navigation-link:unread-count"]',
)) {
const unreadCounter = Ferdium.safeParseInt(counterElement.textContent);
unreadCount = Math.max(unreadCount, unreadCounter);
Expand Down

1 comment on commit 0337750

@oleole39
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! I was annoyed for so long to have Ferdium displaying the "All Mail" folder count instead of Inbox's... Just dug into it, and eventually understood I only had to update the recipe thanks to your changes.

However, I wonder whether some Ferdium users may not be happy with this update as it does not include unread count from custom folders anymore, i.e. if you have a mail filter automatically moving given incoming emails to a custom folder, those would not be displayed as unread messages in Ferdium badge anymore. I fall under this case, but only showing the Inbox folder's unread count has nevertheless been so far exactly what I was after.

I don't need it for now, but a more complex future implementation to have the best of all worlds could be something like having in Ferdium's service's settings a list of folder in which could be selected those to include and compute the sum of their respective counter (or substract from All Mail?). I list below for reference the selectors that might be useful for this if they have not changed until then.

  • All mail: document.querySelectorAll('[data-testid="navigation-link:almost-all-mail"] [data-testid="navigation-link:unread-count"]')[0].textContent;
  • Inbox: document.querySelectorAll('[data-testid="navigation-link:inbox"] [data-testid="navigation-link:unread-count"]')[0].textContent;
  • Custom folder "My Custom Folder": document.querySelectorAll('[data-testid="sidebar-label:My Custom Folder"] [data-testid="navigation-link:unread-count"]')[0].textContent;

Please sign in to comment.