diff options
author | Edgars <eandersons@users.noreply.github.com> | 2023-11-27 15:12:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-27 06:12:31 -0700 |
commit | 82c9444088a632e2b654f2d65d952f5ed07b52bd (patch) | |
tree | c5e39bc6db3dbe0fd5fae59f89773e2c4b0e0ded /recipes/nextcloud-calendar/webview.js | |
parent | chore: update links in pr template (#471) (diff) | |
download | ferdium-recipes-82c9444088a632e2b654f2d65d952f5ed07b52bd.tar.gz ferdium-recipes-82c9444088a632e2b654f2d65d952f5ed07b52bd.tar.zst ferdium-recipes-82c9444088a632e2b654f2d65d952f5ed07b52bd.zip |
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.
Diffstat (limited to 'recipes/nextcloud-calendar/webview.js')
-rw-r--r-- | recipes/nextcloud-calendar/webview.js | 19 |
1 files changed, 10 insertions, 9 deletions
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) { | |||
5 | const _path = _interopRequireDefault(require('path')); | 5 | const _path = _interopRequireDefault(require('path')); |
6 | 6 | ||
7 | module.exports = Ferdium => { | 7 | module.exports = Ferdium => { |
8 | // With `// Legacy ` are marked those selectors that were working for some | ||
9 | // Nextcloud version before 27 (24 or 25). | ||
10 | const notificationElement = '.notification-wrapper .notification'; | ||
8 | const getMessages = () => { | 11 | const getMessages = () => { |
9 | const directSelector = document.querySelectorAll( | 12 | Ferdium.setBadge( |
10 | '.notifications .notification-wrapper .notification[object_type="dav"]', | 13 | Ferdium.safeParseInt( |
14 | document.querySelectorAll( | ||
15 | `.notifications ${notificationElement}[object_type="dav"], ` + // Legacy | ||
16 | `.notification-container ${notificationElement}[data-app="dav"]`, // Nextcloud 27 | ||
17 | )?.length, | ||
18 | ), | ||
11 | ); | 19 | ); |
12 | const direct = directSelector | ||
13 | ? Ferdium.safeParseInt(directSelector.length) | ||
14 | : 0; | ||
15 | |||
16 | Ferdium.setBadge(direct); | ||
17 | }; | 20 | }; |
18 | |||
19 | Ferdium.loop(getMessages); | 21 | Ferdium.loop(getMessages); |
20 | |||
21 | Ferdium.injectCSS(_path.default.join(__dirname, 'service.css')); | 22 | Ferdium.injectCSS(_path.default.join(__dirname, 'service.css')); |
22 | }; | 23 | }; |