From 5283be9f0bcd77dd24920219deabe8e3b72463a2 Mon Sep 17 00:00:00 2001 From: Mattia Panzeri <1754457+panz3r@users.noreply.github.com> Date: Thu, 25 Nov 2021 14:26:58 +0100 Subject: Fix Protonmail unread counter (#773) --- recipes/proton-mail/package.json | 2 +- recipes/proton-mail/webview.js | 18 ++++++++---------- 2 files changed, 9 insertions(+), 11 deletions(-) (limited to 'recipes') diff --git a/recipes/proton-mail/package.json b/recipes/proton-mail/package.json index ab09207..4e89567 100644 --- a/recipes/proton-mail/package.json +++ b/recipes/proton-mail/package.json @@ -1,7 +1,7 @@ { "id": "proton-mail", "name": "ProtonMail", - "version": "1.3.1", + "version": "1.3.2", "license": "MIT", "config": { "serviceURL": "https://mail.protonmail.com/login" diff --git a/recipes/proton-mail/webview.js b/recipes/proton-mail/webview.js index 395b779..89e5dab 100644 --- a/recipes/proton-mail/webview.js +++ b/recipes/proton-mail/webview.js @@ -1,15 +1,13 @@ module.exports = Ferdi => { const getMessages = () => { - const element = document.querySelector('.navigationItem-counter'); - if (!element) { - return; - } - const text = element.textContent; - if (text) { - // eslint-disable-next-line unicorn/prefer-string-slice - const count = Ferdi.safeParseInt(text.substring(1, text.length - 1)); - Ferdi.setBadge(count); - } + let unreadCount = 0; + // Loop over all displayed counters and take the highest one (from the "All Mail" folder) + document.querySelectorAll('.navigation-counter-item').forEach(counterElement => { + const unreadCounter = Ferdi.safeParseInt(counterElement.textContent); + unreadCount = Math.max(unreadCount, unreadCounter); + }); + + Ferdi.setBadge(unreadCount); }; Ferdi.loop(getMessages); -- cgit v1.2.3-54-g00ecf