aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Edgars <Edgars+GitHub@gaitenis.id.lv>2022-12-06 10:57:33 +0200
committerLibravatar Vijay Aravamudhan <vraravam@users.noreply.github.com>2022-12-07 07:04:56 +0530
commitcdd246c08fd4e884d6ac2ded821303200cbf410c (patch)
tree67cac0115caedc98945f6b3126961bcca9144eb0
parentFix notifications count for Nextcloud 25 (diff)
downloadferdium-recipes-cdd246c08fd4e884d6ac2ded821303200cbf410c.tar.gz
ferdium-recipes-cdd246c08fd4e884d6ac2ded821303200cbf410c.tar.zst
ferdium-recipes-cdd246c08fd4e884d6ac2ded821303200cbf410c.zip
Get Element messages count from the spaces navbar
Element recipe was updated to get direct messages count from the spaces navigation bar as previously it was retrieved only from the active space resulting in situations when there are new messages in Element but there is no indicator if the currently active Element space does not have unread notifications.
-rw-r--r--recipes/element/package.json2
-rw-r--r--recipes/element/webview.js25
2 files changed, 8 insertions, 19 deletions
diff --git a/recipes/element/package.json b/recipes/element/package.json
index 58ca48d..beba777 100644
--- a/recipes/element/package.json
+++ b/recipes/element/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "element", 2 "id": "element",
3 "name": "Element", 3 "name": "Element",
4 "version": "1.3.0", 4 "version": "1.3.1",
5 "license": "MIT", 5 "license": "MIT",
6 "aliases": [ 6 "aliases": [
7 "Riot.im", 7 "Riot.im",
diff --git a/recipes/element/webview.js b/recipes/element/webview.js
index ebe557f..3528418 100644
--- a/recipes/element/webview.js
+++ b/recipes/element/webview.js
@@ -1,25 +1,14 @@
1module.exports = Ferdium => { 1module.exports = Ferdium => {
2 function getMessages() { 2 function getMessages() {
3 const badges = document.querySelectorAll('.mx_RoomList .mx_RoomSublist_tiles .mx_NotificationBadge');
4 // Number of messages from rooms which has "All Messages" notifications enabled.
5 // Always incremented for private rooms by default, incremented for group chats if
6 // "All Messages" is selected for them in notifications settings.
7 let directCount = 0; 3 let directCount = 0;
8 // Number of messages for rooms which has "Only Highlights" notifications level set. 4 const spacesBar = document.querySelector('.mx_SpaceTreeLevel');
9 // Appears in rooms list with dots on right. 5 spacesBar.querySelectorAll('.mx_NotificationBadge_count').forEach((badge) => {
10 let indirectCount = 0; 6 directCount += Ferdium.safeParseInt(badge.textContent);
11 7 });
12 for (const badge of badges) { 8 const indirectCount = spacesBar.querySelectorAll('.mx_NotificationBadge_dot')
13 if (badge.classList.contains('mx_NotificationBadge_dot')) { 9 .length;
14 indirectCount++;
15 } else {
16 directCount += Ferdium.safeParseInt(badge.childNodes[0].textContent);
17 }
18 }
19
20 // set Ferdium badge
21 Ferdium.setBadge(directCount, indirectCount); 10 Ferdium.setBadge(directCount, indirectCount);
22 } 11 }
12
23 Ferdium.loop(getMessages); 13 Ferdium.loop(getMessages);
24}; 14};
25