diff options
Diffstat (limited to 'recipes/aws-workmail')
-rw-r--r-- | recipes/aws-workmail/webview.js | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/recipes/aws-workmail/webview.js b/recipes/aws-workmail/webview.js index a979903..c374b55 100644 --- a/recipes/aws-workmail/webview.js +++ b/recipes/aws-workmail/webview.js | |||
@@ -1,24 +1,22 @@ | |||
1 | module.exports = (Franz, options) => { | 1 | module.exports = (Franz, options) => { |
2 | const reload = (EventType) => { | 2 | const reload = (EventType) => new Promise((resolve, reject) => { |
3 | return new Promise((resolve, reject) => { | 3 | const btn = document.getElementsByClassName('giraffe-hierarchy-node-refresh')[0]; |
4 | const btn = document.getElementsByClassName('giraffe-hierarchy-node-refresh')[0]; | 4 | const EventObject = document.createEvent('Events'); |
5 | const EventObject = document.createEvent('Events'); | 5 | EventObject.initEvent(EventType, true, false); |
6 | EventObject.initEvent(EventType, true, false); | ||
7 | 6 | ||
8 | if (btn.dispatchEvent(EventObject)) { | 7 | if (btn.dispatchEvent(EventObject)) { |
9 | resolve(); | 8 | resolve(); |
10 | } else { | 9 | } else { |
11 | reject(); | 10 | reject(); |
12 | } | 11 | } |
13 | }); | 12 | }); |
14 | }; | ||
15 | 13 | ||
16 | const getUnread = () => { | 14 | const getUnread = () => { |
17 | const nodes = document.getElementsByClassName('giraffe-hierarchy-node-counter'); | 15 | const nodes = document.getElementsByClassName('giraffe-hierarchy-node-counter'); |
18 | let counter = 0; | 16 | let counter = 0; |
19 | 17 | ||
20 | for (var i = 0; i < nodes.length; i++) { | 18 | for (let i = 0; i < nodes.length; i++) { |
21 | let node = parseInt(nodes[i].innerText); | 19 | const node = parseInt(nodes[i].innerText); |
22 | counter += (node > 0) ? node : 0; | 20 | counter += (node > 0) ? node : 0; |
23 | } | 21 | } |
24 | 22 | ||
@@ -28,7 +26,7 @@ module.exports = (Franz, options) => { | |||
28 | if (!window.location.pathname.includes('auth')) { | 26 | if (!window.location.pathname.includes('auth')) { |
29 | Franz.loop(getUnread); | 27 | Franz.loop(getUnread); |
30 | 28 | ||
31 | window.setInterval(function() { | 29 | window.setInterval(() => { |
32 | reload('click'); | 30 | reload('click'); |
33 | }, 60000); | 31 | }, 60000); |
34 | } | 32 | } |