diff options
author | Raphael Jenni <RaphaelJenni@users.noreply.github.com> | 2023-01-02 12:10:44 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-02 11:10:44 +0000 |
commit | 042838ec4263950c62f5c1c978dbcd0d529719a1 (patch) | |
tree | c68d9bca7ea89659cffefa014a89b27e8b564a89 /recipes/infomaniak-mail/webview.js | |
parent | Use unread rooms count like Element app does (diff) | |
download | ferdium-recipes-042838ec4263950c62f5c1c978dbcd0d529719a1.tar.gz ferdium-recipes-042838ec4263950c62f5c1c978dbcd0d529719a1.tar.zst ferdium-recipes-042838ec4263950c62f5c1c978dbcd0d529719a1.zip |
Fix: Infomaniak unread messages badge to exclude spam emails (#273)
Diffstat (limited to 'recipes/infomaniak-mail/webview.js')
-rw-r--r-- | recipes/infomaniak-mail/webview.js | 20 |
1 files changed, 17 insertions, 3 deletions
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 @@ | |||
1 | module.exports = Ferdium => { | 1 | module.exports = Ferdium => { |
2 | const getMessages = () => { | 2 | const getMessages = () => { |
3 | const count = document.querySelector('.ws-tree-node-badge'); | 3 | // This selects the first folder (the inbox and reads its unread messages count) |
4 | const countText = count ? count.textContent : null; | 4 | const inboxField = document.querySelector('.ws-tree-node-content') |
5 | Ferdium.setBadge(count && countText ? Number(countText) : 0); | 5 | const inboxCountField = inboxField.querySelector('.ws-tree-node-badge'); |
6 | const inboxCountText = inboxCountField ? inboxCountField.textContent : null; | ||
7 | const inboxCount = inboxCountText ? Ferdium.safeParseInt(inboxCountText) : 0; | ||
8 | |||
9 | let unimportantCount = 0; | ||
10 | |||
11 | if (inboxCount === 0) { | ||
12 | // This selects the first folder with an unread message count. | ||
13 | // The actaul count and the total of all other folders is not needed as the badge has no number. | ||
14 | const totalCountField = document.querySelector('.ws-tree-node-badge'); | ||
15 | const totalCountText = totalCountField ? totalCountField.textContent : null; | ||
16 | unimportantCount = totalCountText ? Ferdium.safeParseInt(totalCountText) : 0; | ||
17 | } | ||
18 | |||
19 | Ferdium.setBadge(inboxCount, unimportantCount); | ||
6 | }; | 20 | }; |
7 | 21 | ||
8 | Ferdium.loop(getMessages); | 22 | Ferdium.loop(getMessages); |