aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/mattermost
diff options
context:
space:
mode:
Diffstat (limited to 'recipes/mattermost')
-rw-r--r--recipes/mattermost/package.json2
-rw-r--r--recipes/mattermost/webview.js18
2 files changed, 15 insertions, 5 deletions
diff --git a/recipes/mattermost/package.json b/recipes/mattermost/package.json
index 52a1908..f30a0a6 100644
--- a/recipes/mattermost/package.json
+++ b/recipes/mattermost/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "mattermost", 2 "id": "mattermost",
3 "name": "Mattermost", 3 "name": "Mattermost",
4 "version": "1.2.2", 4 "version": "1.2.3",
5 "description": "Mattermost", 5 "description": "Mattermost",
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/mattermost/webview.js b/recipes/mattermost/webview.js
index f348da4..c69c370 100644
--- a/recipes/mattermost/webview.js
+++ b/recipes/mattermost/webview.js
@@ -1,13 +1,23 @@
1"use strict"; 1"use strict";
2 2
3module.exports = Franz => { 3module.exports = Franz => {
4 const DIRECT_MESSAGES_INDIVIDUAL = '#sidebar-left .unread-title .DirectChannel__profile-picture';
5 const DIRECT_MESSAGES_GROUP = '#sidebar-left .unread-title .status--group';
6 const DIRECT_MESSAGES_LEGACY = '.sidebar--left .has-badge .badge';
7 const ALL_MESSAGES = '#sidebar-left .unread-title';
8 const ALL_MESSAGES_LEGACY = '#sidebar-left .unread-title';
9
4 const getMessages = function getMessages() { 10 const getMessages = function getMessages() {
5 const directMessages = document.querySelectorAll('.sidebar--left .has-badge .badge').length; 11 const directMessagesSelector = [DIRECT_MESSAGES_LEGACY, DIRECT_MESSAGES_INDIVIDUAL, DIRECT_MESSAGES_GROUP].join(', ');
6 const allMessages = document.querySelectorAll('.sidebar--left .has-badge').length - directMessages; 12 const directMessages = document.querySelectorAll(directMessagesSelector).length;
7 const channelMessages = document.querySelectorAll('.sidebar--left .unread-title').length - allMessages; 13
14 const allMessagesSelector = [ALL_MESSAGES, ALL_MESSAGES_LEGACY].join(', ');
15 const allMessages = document.querySelectorAll(allMessagesSelector).length - directMessages;
16
8 const teamDirectMessages = document.querySelectorAll('.team-wrapper .team-container .badge').length; 17 const teamDirectMessages = document.querySelectorAll('.team-wrapper .team-container .badge').length;
9 const teamMessages = document.querySelectorAll('.team-wrapper .unread').length - teamDirectMessages; 18 const teamMessages = document.querySelectorAll('.team-wrapper .unread').length - teamDirectMessages;
10 Franz.setBadge(directMessages + teamDirectMessages, allMessages + channelMessages + teamMessages); 19
20 Franz.setBadge(directMessages + teamDirectMessages, allMessages + teamMessages);
11 }; 21 };
12 22
13 Franz.loop(getMessages); 23 Franz.loop(getMessages);