diff options
-rw-r--r-- | recipes/infomaniak-mail/package.json | 2 | ||||
-rw-r--r-- | recipes/infomaniak-mail/webview.js | 20 |
2 files changed, 18 insertions, 4 deletions
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 @@ | |||
1 | { | 1 | { |
2 | "id": "infomaniak-mail", | 2 | "id": "infomaniak-mail", |
3 | "name": "Infomaniak Mail", | 3 | "name": "Infomaniak Mail", |
4 | "version": "1.2.0", | 4 | "version": "1.3.0", |
5 | "license": "MIT", | 5 | "license": "MIT", |
6 | "config": { | 6 | "config": { |
7 | "serviceURL": "https://mail.infomaniak.com/" | 7 | "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 @@ | |||
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); |