diff options
Diffstat (limited to 'recipes/rocketchat')
-rw-r--r-- | recipes/rocketchat/package.json | 2 | ||||
-rw-r--r-- | recipes/rocketchat/webview.js | 36 |
2 files changed, 24 insertions, 14 deletions
diff --git a/recipes/rocketchat/package.json b/recipes/rocketchat/package.json index 122a74e..1ac9e9b 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.0.9", | 4 | "version": "1.0.10", |
5 | "description": "Rocket.Chat", | 5 | "description": "Rocket.Chat", |
6 | "main": "index.js", | 6 | "main": "index.js", |
7 | "author": "Stefan Malzner <stefan@adlk.io>", | 7 | "author": "Stefan Malzner <stefan@adlk.io>", |
diff --git a/recipes/rocketchat/webview.js b/recipes/rocketchat/webview.js index 5ccd0d2..447b19b 100644 --- a/recipes/rocketchat/webview.js +++ b/recipes/rocketchat/webview.js | |||
@@ -1,11 +1,8 @@ | |||
1 | "use strict"; | 1 | 'use strict'; |
2 | 2 | ||
3 | const { | 3 | const { ipcRenderer } = require('electron'); |
4 | ipcRenderer | ||
5 | } = require('electron'); | ||
6 | 4 | ||
7 | const getTeamIcon = function getTeamIcon() { | 5 | const getTeamIcon = function getTeamIcon() { |
8 | console.log('getTeamIcon'); | ||
9 | const manifestElement = document.querySelector('link[rel="manifest"]'); | 6 | const manifestElement = document.querySelector('link[rel="manifest"]'); |
10 | 7 | ||
11 | if (manifestElement == null) { | 8 | if (manifestElement == null) { |
@@ -13,7 +10,6 @@ const getTeamIcon = function getTeamIcon() { | |||
13 | } | 10 | } |
14 | 11 | ||
15 | const manifestUrl = manifestElement.getAttribute('href'); | 12 | const manifestUrl = manifestElement.getAttribute('href'); |
16 | console.log(manifestUrl); | ||
17 | 13 | ||
18 | if (manifestUrl == null) { | 14 | if (manifestUrl == null) { |
19 | return; | 15 | return; |
@@ -29,7 +25,10 @@ const getTeamIcon = function getTeamIcon() { | |||
29 | const response = JSON.parse(this.responseText); | 25 | const response = JSON.parse(this.responseText); |
30 | 26 | ||
31 | if (response.icons.length >= 1) { | 27 | if (response.icons.length >= 1) { |
32 | ipcRenderer.sendToHost('avatar', `${window.location.protocol}//${window.location.host}${response.icons[0].src}`); | 28 | ipcRenderer.sendToHost( |
29 | 'avatar', | ||
30 | `${window.location.protocol}//${window.location.host}${response.icons[0].src}` | ||
31 | ); | ||
33 | } | 32 | } |
34 | }; | 33 | }; |
35 | 34 | ||
@@ -37,15 +36,26 @@ const getTeamIcon = function getTeamIcon() { | |||
37 | xmlhttp.send(); | 36 | xmlhttp.send(); |
38 | }; | 37 | }; |
39 | 38 | ||
40 | module.exports = Franz => { | 39 | module.exports = Ferdi => { |
41 | const getMessages = function getMessages() { | 40 | const getMessages = function getMessages() { |
42 | const directMessages = Math.round(document.querySelectorAll('.unread.unread-mention, .badge--unread').length / 2); | 41 | const directMessages = document.querySelectorAll('.rcx-badge'); |
43 | const indirectMessages = Math.round(document.querySelectorAll('.unread:not(.unread-mention), .sidebar-item--unread').length / 2); | 42 | |
44 | Franz.setBadge(directMessages, indirectMessages); | 43 | let directMessagesCount = 0; |
44 | |||
45 | for (const directMessage of directMessages) { | ||
46 | directMessagesCount += parseInt(directMessage.textContent, 10); | ||
47 | } | ||
48 | |||
49 | const indirectMessagesCount = Math.round( | ||
50 | document.querySelectorAll('.rcx-sidebar-item--highlighted').length | ||
51 | ); | ||
52 | |||
53 | Ferdi.setBadge(directMessagesCount, indirectMessagesCount); | ||
45 | }; | 54 | }; |
46 | 55 | ||
47 | Franz.loop(getMessages); | 56 | Ferdi.loop(getMessages); |
57 | |||
48 | setTimeout(() => { | 58 | setTimeout(() => { |
49 | getTeamIcon(); | 59 | getTeamIcon(); |
50 | }, 4000); | 60 | }, 4000); |
51 | }; \ No newline at end of file | 61 | }; |