diff options
author | 2020-11-11 10:14:02 +0200 | |
---|---|---|
committer | 2020-11-11 10:14:02 +0200 | |
commit | 8b7e59d64dc080f8b5c2d91b72aade4545d26c49 (patch) | |
tree | 68e462cba2eb7b08a590c214f331d7339079db5b /recipes/nextcloud-talk/webview.js | |
parent | Nextcloud Talk: Hide unrelated notifications and fix notifications count (diff) | |
download | ferdium-recipes-8b7e59d64dc080f8b5c2d91b72aade4545d26c49.tar.gz ferdium-recipes-8b7e59d64dc080f8b5c2d91b72aade4545d26c49.tar.zst ferdium-recipes-8b7e59d64dc080f8b5c2d91b72aade4545d26c49.zip |
Nextcloud Talk: Fine-tuning for `webview.js`
`webview.js` was updated to get direct notifications count only when
notification wrapper has been loaded.
Diffstat (limited to 'recipes/nextcloud-talk/webview.js')
-rw-r--r-- | recipes/nextcloud-talk/webview.js | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/recipes/nextcloud-talk/webview.js b/recipes/nextcloud-talk/webview.js index 42b1e49..0dfb6ea 100644 --- a/recipes/nextcloud-talk/webview.js +++ b/recipes/nextcloud-talk/webview.js | |||
@@ -8,17 +8,22 @@ function _interopRequireDefault(obj) { | |||
8 | 8 | ||
9 | module.exports = Ferdi => { | 9 | module.exports = Ferdi => { |
10 | const getMessages = function getMessages() { | 10 | const getMessages = function getMessages() { |
11 | const direct = document.querySelector( | 11 | let direct = 0; |
12 | const notificationWrapper = document.querySelector( | ||
12 | '.notifications .notification-wrapper' | 13 | '.notifications .notification-wrapper' |
13 | ).querySelectorAll( | 14 | ); |
14 | '.notification[object_type="chat"], .notification[object_type="room"' | 15 | |
15 | ).length; | 16 | if (notificationWrapper) { |
17 | direct = notificationWrapper.querySelectorAll( | ||
18 | '.notification[object_type="chat"], .notification[object_type="room"' | ||
19 | ).length; | ||
20 | } | ||
16 | 21 | ||
17 | var indirect = 0; | 22 | let indirect = 0; |
18 | 23 | ||
19 | document.querySelectorAll('.app-navigation-entry__counter').forEach( | 24 | document.querySelectorAll('.app-navigation-entry__counter').forEach( |
20 | function(counter) { | 25 | function(counter) { |
21 | indirect += Number(counter.textContent) | 26 | indirect += Number(counter.textContent); |
22 | } | 27 | } |
23 | ); | 28 | ); |
24 | Ferdi.setBadge(direct, indirect); | 29 | Ferdi.setBadge(direct, indirect); |