diff options
author | 2022-12-06 10:57:33 +0200 | |
---|---|---|
committer | 2022-12-07 07:04:56 +0530 | |
commit | cdd246c08fd4e884d6ac2ded821303200cbf410c (patch) | |
tree | 67cac0115caedc98945f6b3126961bcca9144eb0 /recipes/element/webview.js | |
parent | Fix notifications count for Nextcloud 25 (diff) | |
download | ferdium-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.
Diffstat (limited to 'recipes/element/webview.js')
-rw-r--r-- | recipes/element/webview.js | 25 |
1 files changed, 7 insertions, 18 deletions
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 @@ | |||
1 | module.exports = Ferdium => { | 1 | module.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 | |||