From 8b7e59d64dc080f8b5c2d91b72aade4545d26c49 Mon Sep 17 00:00:00 2001 From: Edgars Date: Wed, 11 Nov 2020 10:14:02 +0200 Subject: Nextcloud Talk: Fine-tuning for `webview.js` `webview.js` was updated to get direct notifications count only when notification wrapper has been loaded. --- recipes/nextcloud-talk/webview.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'recipes/nextcloud-talk') 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) { module.exports = Ferdi => { const getMessages = function getMessages() { - const direct = document.querySelector( + let direct = 0; + const notificationWrapper = document.querySelector( '.notifications .notification-wrapper' - ).querySelectorAll( - '.notification[object_type="chat"], .notification[object_type="room"' - ).length; + ); + + if (notificationWrapper) { + direct = notificationWrapper.querySelectorAll( + '.notification[object_type="chat"], .notification[object_type="room"' + ).length; + } - var indirect = 0; + let indirect = 0; document.querySelectorAll('.app-navigation-entry__counter').forEach( function(counter) { - indirect += Number(counter.textContent) + indirect += Number(counter.textContent); } ); Ferdi.setBadge(direct, indirect); -- cgit v1.2.3-54-g00ecf