aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Max Rydahl Andersen <max.andersen@gmail.com>2023-12-15 01:44:51 +0100
committerLibravatar GitHub <noreply@github.com>2023-12-14 17:44:51 -0700
commit6a74a1bb8cb12e7de4e011870eb0e62d666b3be9 (patch)
tree4ea18cb839852e3c39b5d56fa76c01c4369f4601
parentAdd Diagrams.net service recipe (#477) (diff)
downloadferdium-recipes-6a74a1bb8cb12e7de4e011870eb0e62d666b3be9.tar.gz
ferdium-recipes-6a74a1bb8cb12e7de4e011870eb0e62d666b3be9.tar.zst
ferdium-recipes-6a74a1bb8cb12e7de4e011870eb0e62d666b3be9.zip
Zulip changed unread locations (#478)
-rw-r--r--recipes/zulip/package.json2
-rw-r--r--recipes/zulip/webview.js39
2 files changed, 30 insertions, 11 deletions
diff --git a/recipes/zulip/package.json b/recipes/zulip/package.json
index dce1826..323a26c 100644
--- a/recipes/zulip/package.json
+++ b/recipes/zulip/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "zulip", 2 "id": "zulip",
3 "name": "Zulip", 3 "name": "Zulip",
4 "version": "1.3.0", 4 "version": "1.4.0",
5 "license": "MIT", 5 "license": "MIT",
6 "config": { 6 "config": {
7 "hasNotificationSound": true, 7 "hasNotificationSound": true,
diff --git a/recipes/zulip/webview.js b/recipes/zulip/webview.js
index 707b723..a63d49e 100644
--- a/recipes/zulip/webview.js
+++ b/recipes/zulip/webview.js
@@ -5,27 +5,46 @@ function _interopRequireDefault(obj) {
5const _path = _interopRequireDefault(require('path')); 5const _path = _interopRequireDefault(require('path'));
6 6
7module.exports = Ferdium => { 7module.exports = Ferdium => {
8 function getUnreadCount(eltClassName) { 8 function getUnreadMentions() {
9 const elt = document.querySelectorAll( 9 const anchorWithMentionHref = document.querySelector(
10 `#global_filters .${eltClassName} .unread_count`, 10 'a[href*="is/mentioned"]',
11 )[0]; 11 );
12 return elt === null ? 0 : Ferdium.safeParseInt(elt.textContent); 12 const unreadCountElement =
13 anchorWithMentionHref.querySelector('.unread_count');
14
15 return unreadCountElement == null
16 ? 0
17 : Ferdium.safeParseInt(unreadCountElement.textContent);
13 } 18 }
14 19
20 function getUnreadCount(eltId) {
21 const elt = document.querySelectorAll(`#${eltId} + .unread_count`)[0];
22 return elt == null ? 0 : Ferdium.safeParseInt(elt.textContent);
23 }
24
25 function getStreamsUnread() {
26 const streamsHeader = document.querySelector('#streams_header');
27 const unreadCountElement = streamsHeader.querySelector('.unread_count');
28
29 return unreadCountElement == null
30 ? 0
31 : Ferdium.safeParseInt(unreadCountElement.textContent);
32 }
33
34 //document.querySelector('#show_all_private_messages + .unread_count')
15 const getMessages = () => { 35 const getMessages = () => {
16 // All unread messages 36 // All unread messages
17 const unreadAll = getUnreadCount('top_left_all_messages'); 37 const streamUnread = getStreamsUnread();
18 38
19 // Private messages 39 // Private messages
20 const unreadPrivate = getUnreadCount('top_left_private_messages'); 40 const unreadPrivate = getUnreadCount('show_all_private_messages');
21 41
22 // @ Mentions messages 42 // @ Mentions messages
23 const unreadMentions = getUnreadCount('top_left_mentions'); 43 const unreadMentions = getUnreadMentions();
24 44
25 const directMessages = unreadPrivate + unreadMentions; 45 const directMessages = unreadPrivate + unreadMentions;
26 const indirectMessages = unreadAll - directMessages;
27 46
28 Ferdium.setBadge(directMessages, indirectMessages); 47 Ferdium.setBadge(directMessages, streamUnread);
29 }; 48 };
30 49
31 Ferdium.loop(getMessages); 50 Ferdium.loop(getMessages);