From 042838ec4263950c62f5c1c978dbcd0d529719a1 Mon Sep 17 00:00:00 2001 From: Raphael Jenni Date: Mon, 2 Jan 2023 12:10:44 +0100 Subject: Fix: Infomaniak unread messages badge to exclude spam emails (#273) --- recipes/infomaniak-mail/package.json | 2 +- recipes/infomaniak-mail/webview.js | 20 +++++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) (limited to 'recipes/infomaniak-mail') diff --git a/recipes/infomaniak-mail/package.json b/recipes/infomaniak-mail/package.json index 64a9e91..a90ce82 100644 --- a/recipes/infomaniak-mail/package.json +++ b/recipes/infomaniak-mail/package.json @@ -1,7 +1,7 @@ { "id": "infomaniak-mail", "name": "Infomaniak Mail", - "version": "1.2.0", + "version": "1.3.0", "license": "MIT", "config": { "serviceURL": "https://mail.infomaniak.com/" diff --git a/recipes/infomaniak-mail/webview.js b/recipes/infomaniak-mail/webview.js index 940eb82..23516b2 100644 --- a/recipes/infomaniak-mail/webview.js +++ b/recipes/infomaniak-mail/webview.js @@ -1,8 +1,22 @@ module.exports = Ferdium => { const getMessages = () => { - const count = document.querySelector('.ws-tree-node-badge'); - const countText = count ? count.textContent : null; - Ferdium.setBadge(count && countText ? Number(countText) : 0); + // This selects the first folder (the inbox and reads its unread messages count) + const inboxField = document.querySelector('.ws-tree-node-content') + const inboxCountField = inboxField.querySelector('.ws-tree-node-badge'); + const inboxCountText = inboxCountField ? inboxCountField.textContent : null; + const inboxCount = inboxCountText ? Ferdium.safeParseInt(inboxCountText) : 0; + + let unimportantCount = 0; + + if (inboxCount === 0) { + // This selects the first folder with an unread message count. + // The actaul count and the total of all other folders is not needed as the badge has no number. + const totalCountField = document.querySelector('.ws-tree-node-badge'); + const totalCountText = totalCountField ? totalCountField.textContent : null; + unimportantCount = totalCountText ? Ferdium.safeParseInt(totalCountText) : 0; + } + + Ferdium.setBadge(inboxCount, unimportantCount); }; Ferdium.loop(getMessages); -- cgit v1.2.3-70-g09d2