소스 검색

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);
 }