diff options
Diffstat (limited to 'recipes/rocketchat')
-rw-r--r-- | recipes/rocketchat/package.json | 2 | ||||
-rw-r--r-- | recipes/rocketchat/webview.js | 24 |
2 files changed, 13 insertions, 13 deletions
diff --git a/recipes/rocketchat/package.json b/recipes/rocketchat/package.json index 164cd5f..92c245a 100644 --- a/recipes/rocketchat/package.json +++ b/recipes/rocketchat/package.json | |||
@@ -1,7 +1,7 @@ | |||
1 | { | 1 | { |
2 | "id": "rocketchat", | 2 | "id": "rocketchat", |
3 | "name": "Rocket.Chat", | 3 | "name": "Rocket.Chat", |
4 | "version": "1.4.0", | 4 | "version": "1.5.0", |
5 | "license": "MIT", | 5 | "license": "MIT", |
6 | "config": { | 6 | "config": { |
7 | "serviceURL": "https://{teamId}.rocket.chat", | 7 | "serviceURL": "https://{teamId}.rocket.chat", |
diff --git a/recipes/rocketchat/webview.js b/recipes/rocketchat/webview.js index 74556de..67f50f1 100644 --- a/recipes/rocketchat/webview.js +++ b/recipes/rocketchat/webview.js | |||
@@ -6,19 +6,19 @@ const _path = _interopRequireDefault(require('path')); | |||
6 | 6 | ||
7 | module.exports = Ferdium => { | 7 | module.exports = Ferdium => { |
8 | const getMessages = () => { | 8 | const getMessages = () => { |
9 | const directMessages = document.querySelectorAll('.rcx-badge'); | 9 | const title = document.querySelector('title'); |
10 | 10 | const matches = title.textContent.match(/^\((\S*?)\)/); | |
11 | let directMessagesCount = 0; | 11 | |
12 | 12 | if (matches) { | |
13 | for (const directMessage of directMessages) { | 13 | const count = Ferdium.safeParseInt(matches[1], 10); |
14 | directMessagesCount += Ferdium.safeParseInt(directMessage.textContent); | 14 | if (count) { |
15 | Ferdium.setBadge(count); | ||
16 | } else { | ||
17 | Ferdium.setBadge(0, 1); | ||
18 | } | ||
19 | } else { | ||
20 | Ferdium.setBadge(0); | ||
15 | } | 21 | } |
16 | |||
17 | const indirectMessagesCount = Math.round( | ||
18 | document.querySelectorAll('.rcx-sidebar-item--highlighted').length, | ||
19 | ); | ||
20 | |||
21 | Ferdium.setBadge(directMessagesCount, indirectMessagesCount); | ||
22 | }; | 22 | }; |
23 | 23 | ||
24 | Ferdium.loop(getMessages); | 24 | Ferdium.loop(getMessages); |