aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/infomaniak-mail/webview.js
diff options
context:
space:
mode:
Diffstat (limited to 'recipes/infomaniak-mail/webview.js')
-rw-r--r--recipes/infomaniak-mail/webview.js20
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 @@
1module.exports = Ferdium => { 1module.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);