From 82c9444088a632e2b654f2d65d952f5ed07b52bd Mon Sep 17 00:00:00 2001 From: Edgars Date: Mon, 27 Nov 2023 15:12:31 +0200 Subject: Fix selectors in the Nextcloud Calendar recipe (#472) Script and CSS was updated to add selectors for the latest Nextcloud (27). Previous selectors were left as is for backwards compatibility. --- recipes/nextcloud-calendar/webview.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'recipes/nextcloud-calendar/webview.js') diff --git a/recipes/nextcloud-calendar/webview.js b/recipes/nextcloud-calendar/webview.js index 2755cab..3ff240f 100644 --- a/recipes/nextcloud-calendar/webview.js +++ b/recipes/nextcloud-calendar/webview.js @@ -5,18 +5,19 @@ function _interopRequireDefault(obj) { const _path = _interopRequireDefault(require('path')); module.exports = Ferdium => { + // With `// Legacy ` are marked those selectors that were working for some + // Nextcloud version before 27 (24 or 25). + const notificationElement = '.notification-wrapper .notification'; const getMessages = () => { - const directSelector = document.querySelectorAll( - '.notifications .notification-wrapper .notification[object_type="dav"]', + Ferdium.setBadge( + Ferdium.safeParseInt( + document.querySelectorAll( + `.notifications ${notificationElement}[object_type="dav"], ` + // Legacy + `.notification-container ${notificationElement}[data-app="dav"]`, // Nextcloud 27 + )?.length, + ), ); - const direct = directSelector - ? Ferdium.safeParseInt(directSelector.length) - : 0; - - Ferdium.setBadge(direct); }; - Ferdium.loop(getMessages); - Ferdium.injectCSS(_path.default.join(__dirname, 'service.css')); }; -- cgit v1.2.3-70-g09d2