diff options
Diffstat (limited to 'recipes/mattermost')
-rw-r--r-- | recipes/mattermost/index.js | 33 | ||||
-rw-r--r-- | recipes/mattermost/package.json | 2 | ||||
-rw-r--r-- | recipes/mattermost/webview.js | 37 |
3 files changed, 48 insertions, 24 deletions
diff --git a/recipes/mattermost/index.js b/recipes/mattermost/index.js index fca10e1..74ab2ee 100644 --- a/recipes/mattermost/index.js +++ b/recipes/mattermost/index.js | |||
@@ -1,17 +1,18 @@ | |||
1 | module.exports = Ferdium => class Mattermost extends Ferdium { | 1 | module.exports = Ferdium => |
2 | async validateUrl(url) { | 2 | class Mattermost extends Ferdium { |
3 | try { | 3 | async validateUrl(url) { |
4 | const resp = await window.fetch(url, { | 4 | try { |
5 | method: 'GET', | 5 | const resp = await window.fetch(url, { |
6 | headers: { | 6 | method: 'GET', |
7 | 'Content-Type': 'application/json', | 7 | headers: { |
8 | }, | 8 | 'Content-Type': 'application/json', |
9 | }); | 9 | }, |
10 | return resp.status.toString().startsWith('2'); | 10 | }); |
11 | } catch (error) { | 11 | return resp.status.toString().startsWith('2'); |
12 | console.error(error); | 12 | } catch (error) { |
13 | } | 13 | console.error(error); |
14 | } | ||
14 | 15 | ||
15 | return false; | 16 | return false; |
16 | } | 17 | } |
17 | }; | 18 | }; |
diff --git a/recipes/mattermost/package.json b/recipes/mattermost/package.json index 457973d..cbdcbda 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.4.0", | 4 | "version": "1.5.0", |
5 | "license": "MIT", | 5 | "license": "MIT", |
6 | "config": { | 6 | "config": { |
7 | "hasNotificationSound": true, | 7 | "hasNotificationSound": true, |
diff --git a/recipes/mattermost/webview.js b/recipes/mattermost/webview.js index 32e990e..716848e 100644 --- a/recipes/mattermost/webview.js +++ b/recipes/mattermost/webview.js | |||
@@ -1,22 +1,45 @@ | |||
1 | function _interopRequireDefault(obj) { | ||
2 | return obj && obj.__esModule ? obj : { default: obj }; | ||
3 | } | ||
4 | |||
5 | const _path = _interopRequireDefault(require('path')); | ||
6 | |||
1 | module.exports = Ferdium => { | 7 | module.exports = Ferdium => { |
2 | const DIRECT_MESSAGES_INDIVIDUAL = '#sidebar-left .unread-title .DirectChannel__profile-picture'; | 8 | const DIRECT_MESSAGES_INDIVIDUAL = |
9 | '#sidebar-left .unread-title .DirectChannel__profile-picture'; | ||
3 | const DIRECT_MESSAGES_GROUP = '#sidebar-left .unread-title .status--group'; | 10 | const DIRECT_MESSAGES_GROUP = '#sidebar-left .unread-title .status--group'; |
4 | const DIRECT_MESSAGES_LEGACY = '.sidebar--left .has-badge .badge'; | 11 | const DIRECT_MESSAGES_LEGACY = '.sidebar--left .has-badge .badge'; |
5 | const ALL_MESSAGES = '#sidebar-left .unread-title'; | 12 | const ALL_MESSAGES = '#sidebar-left .unread-title'; |
6 | const ALL_MESSAGES_LEGACY = '#sidebar-left .unread-title'; | 13 | const ALL_MESSAGES_LEGACY = '#sidebar-left .unread-title'; |
7 | 14 | ||
8 | const getMessages = () => { | 15 | const getMessages = () => { |
9 | const directMessagesSelector = [DIRECT_MESSAGES_LEGACY, DIRECT_MESSAGES_INDIVIDUAL, DIRECT_MESSAGES_GROUP].join(', '); | 16 | const directMessagesSelector = [ |
10 | const directMessages = document.querySelectorAll(directMessagesSelector).length; | 17 | DIRECT_MESSAGES_LEGACY, |
18 | DIRECT_MESSAGES_INDIVIDUAL, | ||
19 | DIRECT_MESSAGES_GROUP, | ||
20 | ].join(', '); | ||
21 | const directMessages = document.querySelectorAll( | ||
22 | directMessagesSelector, | ||
23 | ).length; | ||
11 | 24 | ||
12 | const allMessagesSelector = [ALL_MESSAGES, ALL_MESSAGES_LEGACY].join(', '); | 25 | const allMessagesSelector = [ALL_MESSAGES, ALL_MESSAGES_LEGACY].join(', '); |
13 | const allMessages = document.querySelectorAll(allMessagesSelector).length - directMessages; | 26 | const allMessages = |
27 | document.querySelectorAll(allMessagesSelector).length - directMessages; | ||
14 | 28 | ||
15 | const teamDirectMessages = document.querySelectorAll('.team-wrapper .team-container .badge').length; | 29 | const teamDirectMessages = document.querySelectorAll( |
16 | const teamMessages = document.querySelectorAll('.team-wrapper .unread').length - teamDirectMessages; | 30 | '.team-wrapper .team-container .badge', |
31 | ).length; | ||
32 | const teamMessages = | ||
33 | document.querySelectorAll('.team-wrapper .unread').length - | ||
34 | teamDirectMessages; | ||
17 | 35 | ||
18 | Ferdium.setBadge(directMessages + teamDirectMessages, allMessages + teamMessages); | 36 | Ferdium.setBadge( |
37 | directMessages + teamDirectMessages, | ||
38 | allMessages + teamMessages, | ||
39 | ); | ||
19 | }; | 40 | }; |
20 | 41 | ||
21 | Ferdium.loop(getMessages); | 42 | Ferdium.loop(getMessages); |
43 | |||
44 | Ferdium.injectCSS(_path.default.join(__dirname, 'service.css')); | ||
22 | }; | 45 | }; |