浏览代码

cumulative bugfix regarding the following issues:

1) unhandled exception on new message arriving when user has not permitted playing audio in the browser
2) incorrect unread messages counter badge on the application icon after switching to new XMPP user
igor 1 年之前
父节点
当前提交
6b2a641cd2
共有 2 个文件被更改,包括 9 次插入1 次删除
  1. 2 0
      CHANGES.md
  2. 7 1
      src/plugins/notifications/utils.js

+ 2 - 0
CHANGES.md

@@ -2,6 +2,8 @@
 
 ## 11.0.0 (Unreleased)
 
+- Fix: unhandled exception on new message arriving when user has not permitted playing audio in the browser
+- Fix: incorrect unread messages counter badge on the application icon after switching to new XMPP user
 - #1174: Show MUC avatars in the rooms list
 - #1195: Add actions to quote and copy messages
 - #1349: XEP-0392 Consistent Color Generation

+ 7 - 1
src/plugins/notifications/utils.js

@@ -34,6 +34,7 @@ export function areDesktopNotificationsEnabled () {
  */
 
 export function clearFavicon () {
+    favicon?.badge(0);
     favicon = null;
     /** @type navigator */(navigator).clearAppBadge?.()
         .catch(e => log.error("Could not clear unread count in app badge " + e));
@@ -302,7 +303,12 @@ export async function handleMessageNotification (data) {
      * @example _converse.api.listen.on('messageNotification', data => { ... });
      */
     api.trigger('messageNotification', data);
-    playSoundNotification();
+    try{
+        playSoundNotification();
+    } catch (error) {
+        // Likely "play() failed because the user didn't interact with the document first"
+        log.error(error);
+    }
     showMessageNotification(data);
 }