Browse Source

bugfix: unhandled exception in disconnect function

when controlbox is not shown by UI
igor 1 year ago
parent
commit
92d96acad5
2 changed files with 10 additions and 5 deletions
  1. 3 2
      CHANGES.md
  2. 7 3
      src/plugins/controlbox/utils.js

+ 3 - 2
CHANGES.md

@@ -2,8 +2,6 @@
 
 ## 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
@@ -22,6 +20,9 @@
 - Fix: refresh the MUC sidebar when participants collection is sorted
 - Fix: room information not correctly refreshed when modifications are made by other users
 - Fix: prevent busy-loop when session resumption fails
+- 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
+- Fix: unhandled exception in disconnect function when controlbox is not shown by UI
 - Add an occupants filter to the MUC sidebar
 - Change contacts filter to rename the anachronistic `Online` state to `Available`.
 - Enable [reuse_scram_keys](https://conversejs.org/docs/html/configuration.html#reuse-scram-keys) by default.

+ 7 - 3
src/plugins/controlbox/utils.js

@@ -26,9 +26,12 @@ export function disconnect () {
      * we reconnect, "onConnected" will be called,
      * to fetch the roster again and to send out a presence stanza.
      */
-    const view = _converse.state.chatboxviews.get('controlbox');
-    view.model.set({ 'connected': false });
-    return view;
+    try{
+        const view = _converse.state.chatboxviews.get('controlbox');
+        view.model.set({ 'connected': false });
+        return view;
+    } catch(error){}
+    return {};
 }
 
 export function clearSession () {
@@ -102,3 +105,4 @@ export function validateJID (form) {
     jid_element.setCustomValidity('');
     return true;
 }
+