aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--recipes/nextcloud-talk/package.json2
-rw-r--r--recipes/nextcloud-talk/service.css52
-rw-r--r--recipes/nextcloud-talk/webview.js50
3 files changed, 62 insertions, 42 deletions
diff --git a/recipes/nextcloud-talk/package.json b/recipes/nextcloud-talk/package.json
index aaf779f..4de0dfb 100644
--- a/recipes/nextcloud-talk/package.json
+++ b/recipes/nextcloud-talk/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "nextcloud-talk", 2 "id": "nextcloud-talk",
3 "name": "Nextcloud Talk", 3 "name": "Nextcloud Talk",
4 "version": "1.4.0", 4 "version": "1.4.1",
5 "license": "MIT", 5 "license": "MIT",
6 "repository": "https://github.com/csolisr/ferdium-recipes/tree/master/recipes/nextcloud-tasks/", 6 "repository": "https://github.com/csolisr/ferdium-recipes/tree/master/recipes/nextcloud-tasks/",
7 "config": { 7 "config": {
diff --git a/recipes/nextcloud-talk/service.css b/recipes/nextcloud-talk/service.css
index ccdba58..e616dd6 100644
--- a/recipes/nextcloud-talk/service.css
+++ b/recipes/nextcloud-talk/service.css
@@ -1,25 +1,43 @@
1/* Hide all app links in the top menu except for Talk */ 1/*
2#appmenu li:not([data-id="spreed"]) { 2With `/* Legacy [asterisk]/` are marked those selectors that were working for
3some Nextcloud version before 27 (24 or 25).
4*/
5
6/*Hide all interactive elements that are not related to the Talk. */
7/* App links and contacts menu link in the top menu except for Talk. */
8#appmenu li:not([data-id="spreed"]), /* Legacy */
9.app-menu .app-menu-main > .app-menu-entry:not([data-app-id="spreed"]),
10#unified-search,
11#contactsmenu,
12/* All settings options, except the option to log out */
13#settings #expanddiv li:not([data-id='logout']), /* Legacy */
14#header-menu-user-menu li:not([id='logout']), /* Nextcloud 27 */
15/* Hide notifications that are not related to Talk */
16.notification-container .notification-wrapper .notification:not([data-app="spreed"]),
17/* "Dismiss all notifications" as this action will dismiss also hidden
18notifications as this behaviour might not be desirable. */
19.notification-wrapper .dismiss-all, /* Legacy */
20#header-menu-notifications .notification-container .dismiss-all /* Nextcloud 27 */ {
3 display: none; 21 display: none;
4} 22}
5 23
6/* Change cursor to the default pointer for top menu Nextcloud home and Talk 24/* Change cursor to the default pointer for top menu Nextcloud home and Talk
7links and disable them */ 25links and disable them */
8#nextcloud, 26#nextcloud,
9#appmenu li[data-id="spreed"] a { 27#appmenu li[data-id="spreed"] a, /* Legacy */
28.app-menu-main li[data-app-id="spreed"] a /* Nextcloud 27 */ {
10 cursor: default; 29 cursor: default;
11 pointer-events: none; 30 pointer-events: none;
12} 31}
13 32
14/* Hide all settings options, except the option to log out */
15#settings #expanddiv li:not([data-id='logout']) {
16 display: none;
17}
18
19/* Fix the margin of the dropdown */ 33/* Fix the margin of the dropdown */
20#settings #expanddiv, 34#settings #expanddiv, /* Legacy */
21#settings #expanddiv > ul { 35#settings #expanddiv > ul, /* Legacy */
22 min-height: 0; 36#header-menu-user-menu, /* Nextcloud 27 */
37#header-menu-user-menu > .header-menu__content, /* Nextcloud 27 */
38#header-menu-notifications, /* Nextcloud 27 */
39#header-menu-notifications > .header-menu__content /* Nextcloud 27 */ {
40 min-height: auto;
23} 41}
24 42
25/* Hide "More" link in the top menu */ 43/* Hide "More" link in the top menu */
@@ -28,16 +46,10 @@ links and disable them */
28} 46}
29 47
30/* Hide notifications that are not related to Talk */ 48/* Hide notifications that are not related to Talk */
31.notifications .notification-wrapper .notification { 49.notifications .notification-wrapper .notification /* Legacy */ {
32 display: none; 50 display: none;
33} 51}
34.notifications .notification-wrapper .notification[object_type="chat"], 52.notifications .notification-wrapper .notification[object_type="chat"], /* Legacy */
35.notifications .notification-wrapper .notification[object_type="room"] { 53.notifications .notification-wrapper .notification[object_type="room"] /* Legacy */ {
36 display: initial; 54 display: initial;
37} 55}
38
39/* Hide "Dismiss all notifications" as this action will dismiss also hidden
40notifications */
41.notification-wrapper .dismiss-all {
42 display: none;
43}
diff --git a/recipes/nextcloud-talk/webview.js b/recipes/nextcloud-talk/webview.js
index 0c7f5c2..15f4dfb 100644
--- a/recipes/nextcloud-talk/webview.js
+++ b/recipes/nextcloud-talk/webview.js
@@ -6,38 +6,46 @@ const _path = _interopRequireDefault(require('path'));
6 6
7module.exports = Ferdium => { 7module.exports = Ferdium => {
8 const getMessages = () => { 8 const getMessages = () => {
9 let direct = 0; 9 // With `// Legacy ` are marked those selectors that were working for some
10 10 // Nextcloud version before 27 (24 or 25).
11 const notificationWrapper = document.querySelector( 11 const counterBubble = '.counter-bubble__counter';
12 '.notifications .notification-wrapper', 12 const directFromLeftSideBar = document.querySelectorAll(
13 ); 13 `${counterBubble}--highlighted`, // Nextcloud 27
14 14 ).length;
15 if (notificationWrapper) {
16 const directSelector = notificationWrapper.querySelectorAll(
17 '.notification[object_type="chat"], .notification[object_type="room"]',
18 );
19 direct = directSelector ? Ferdium.safeParseInt(directSelector.length) : 0;
20 }
21
22 let indirect = 0; 15 let indirect = 0;
23
24 for (const counter of document.querySelectorAll( 16 for (const counter of document.querySelectorAll(
25 '.app-navigation-entry__counter', 17 '.app-navigation-entry__counter, ' + // Legacy
18 `${counterBubble}:not(${counterBubble}--highlighted)`, // Nextcloud 27
26 )) { 19 )) {
27 const entryCounter = counter 20 indirect += Ferdium.safeParseInt(counter?.textContent.trim());
28 ? Ferdium.safeParseInt(counter.textContent)
29 : 0;
30 indirect += entryCounter;
31 } 21 }
32 22
33 if (document.title.startsWith('*')) { 23 if (document.title.startsWith('*')) {
34 indirect += 1; 24 indirect += 1;
35 } 25 }
36 26
37 Ferdium.setBadge(direct, indirect); 27 Ferdium.setBadge(
28 // Try to use the unread conversations count retrieved from the left
29 // sidebar, otherwise check Talk specific notifications
30 directFromLeftSideBar > 0
31 ? directFromLeftSideBar
32 : Ferdium.safeParseInt(
33 document
34 .querySelector(
35 '.notifications .notification-wrapper, ' + // Legacy
36 '.notification-container .notification-wrapper', // Nextcloud 27
37 )
38 ?.querySelectorAll(
39 '.notification[object_type="chat"], ' + // Legacy
40 '.notification[object_type="room"], ' + // Legacy
41 '.notification[data-object-type="chat"], ' + // Nextcloud 27
42 '.notification[data-object-type="room"]', // Nextcloud 27
43 ).length,
44 ),
45 indirect,
46 );
38 }; 47 };
39 48
40 Ferdium.loop(getMessages); 49 Ferdium.loop(getMessages);
41
42 Ferdium.injectCSS(_path.default.join(__dirname, 'service.css')); 50 Ferdium.injectCSS(_path.default.join(__dirname, 'service.css'));
43}; 51};