فهرست منبع

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)
 ## 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
 - #1174: Show MUC avatars in the rooms list
 - #1195: Add actions to quote and copy messages
 - #1195: Add actions to quote and copy messages
 - #1349: XEP-0392 Consistent Color Generation
 - #1349: XEP-0392 Consistent Color Generation

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

@@ -34,6 +34,7 @@ export function areDesktopNotificationsEnabled () {
  */
  */
 
 
 export function clearFavicon () {
 export function clearFavicon () {
+    favicon?.badge(0);
     favicon = null;
     favicon = null;
     /** @type navigator */(navigator).clearAppBadge?.()
     /** @type navigator */(navigator).clearAppBadge?.()
         .catch(e => log.error("Could not clear unread count in app badge " + e));
         .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 => { ... });
      * @example _converse.api.listen.on('messageNotification', data => { ... });
      */
      */
     api.trigger('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);
     showMessageNotification(data);
 }
 }