瀏覽代碼

fix #2409 - Integrate App Badging API for unread messages

Dele Olajide 4 年之前
父節點
當前提交
61dacfd2a5
共有 2 個文件被更改,包括 5 次插入0 次删除
  1. 1 0
      CHANGES.md
  2. 4 0
      src/plugins/notifications/utils.js

+ 1 - 0
CHANGES.md

@@ -5,6 +5,7 @@
 - #1083: Add support for XEP-0393 Message Styling
 - #2275: Allow punctuation to immediately precede a mention
 - #2400: Fixes infinite loop bug when appending .png to allowed image urls
+- #2409: Integrate App Badging API for unread messages
 - Add support for XEP-0437 Room Activity Indicators see [muc-subscribe-to-rai](https://conversejs.org/docs/html/configuration.html#muc-subscribe-to-rai)
 - Bugfix: Use real JID in XEP-0372 references only when the MUC is non-anonymous
 - Bugfix: Connection protocol not updated based on XEP-0156 connection methods

+ 4 - 0
src/plugins/notifications/utils.js

@@ -25,6 +25,8 @@ export function areDesktopNotificationsEnabled () {
 
 export function clearFavicon () {
     favicon = null;
+    navigator.clearAppBadge?.()
+        .catch(e => log.error("Could not clear unread count in app badge " + e));
 }
 
 export function updateUnreadFavicon () {
@@ -33,6 +35,8 @@ export function updateUnreadFavicon () {
         const chats = _converse.chatboxes.models;
         const num_unread = chats.reduce((acc, chat) => acc + (chat.get('num_unread') || 0), 0);
         favicon.badge(num_unread);
+        navigator.setAppBadge?.(num_unread)
+            .catch(e => log.error("Could set unread count in app badge - " + e));
     }
 }