Browse Source

controlbox: Set `connected` immediately

JC Brand 8 years ago
parent
commit
bc6b5ca930
1 changed files with 6 additions and 9 deletions
  1. 6 9
      src/converse-controlbox.js

+ 6 - 9
src/converse-controlbox.js

@@ -102,12 +102,11 @@
                 },
                 },
 
 
                 onChatBoxesFetched (collection, resp) {
                 onChatBoxesFetched (collection, resp) {
-                    const { _converse } = this.__super__;
                     this.__super__.onChatBoxesFetched.apply(this, arguments);
                     this.__super__.onChatBoxesFetched.apply(this, arguments);
+                    const { _converse } = this.__super__;
                     if (!_.includes(_.map(collection, 'id'), 'controlbox')) {
                     if (!_.includes(_.map(collection, 'id'), 'controlbox')) {
-                        _converse.addControlBox();
+                        _converse.addControlBox({'connected': true});
                     }
                     }
-                    this.get('controlbox').save({connected:true});
                 },
                 },
             },
             },
 
 
@@ -159,7 +158,6 @@
                 }
                 }
             },
             },
 
 
-
             ChatBox: {
             ChatBox: {
                 initialize () {
                 initialize () {
                     if (this.get('id') === 'controlbox') {
                     if (this.get('id') === 'controlbox') {
@@ -170,7 +168,6 @@
                 },
                 },
             },
             },
 
 
-
             ChatBoxView: {
             ChatBoxView: {
                 insertIntoDOM () {
                 insertIntoDOM () {
                     const { _converse } = this.__super__;
                     const { _converse } = this.__super__;
@@ -199,14 +196,14 @@
 
 
             const LABEL_CONTACTS = __('Contacts');
             const LABEL_CONTACTS = __('Contacts');
 
 
-            _converse.addControlBox = () =>
-                _converse.chatboxes.add({
+            _converse.addControlBox = (settings) => {
+                _converse.chatboxes.add(_.assign({
                     id: 'controlbox',
                     id: 'controlbox',
                     box_id: 'controlbox',
                     box_id: 'controlbox',
                     type: 'controlbox',
                     type: 'controlbox',
                     closed: !_converse.show_controlbox_by_default
                     closed: !_converse.show_controlbox_by_default
-                })
-            ;
+                }, settings))
+            };
 
 
             _converse.ControlBoxView = _converse.ChatBoxView.extend({
             _converse.ControlBoxView = _converse.ChatBoxView.extend({
                 tagName: 'div',
                 tagName: 'div',