converse-controlbox: Use event listeners instead of (removed) overrides
Due to changes in `converse-core` the controlbox wasn't aware anymore of disconnection or reconnection events.
This commit is contained in:
parent
f0a454561b
commit
be25c688ff
|
@ -3,6 +3,8 @@
|
|||
## 2.0.4 (Unreleased)
|
||||
- Bugfix. Switching from bookmarks form to config form shows only the spinner. [jcbrand]
|
||||
- Bugfix. Other room occupants sometimes not shown when reloading the page. [jcbrand]
|
||||
- Bugfix. Due to changes in `converse-core` the controlbox wasn't aware anymore of
|
||||
disconnection or reconnection events. [jcbrand]
|
||||
- Optimize fetching of MAM messages (in some cases happened on each page load). [jcbrand]
|
||||
|
||||
## 2.0.3 (2016-11-30)
|
||||
|
|
|
@ -91,32 +91,6 @@
|
|||
}
|
||||
},
|
||||
|
||||
onDisconnected: function () {
|
||||
var result = this.__super__.onDisconnected.apply(this, arguments);
|
||||
// Set connected to `false`, so that if we reconnect,
|
||||
// "onConnected" will be called, to fetch the roster again and
|
||||
// to send out a presence stanza.
|
||||
var view = converse.chatboxviews.get('controlbox');
|
||||
view.model.set({connected:false});
|
||||
// If we're not going to reconnect, then render the login
|
||||
// panel.
|
||||
if (result === 'disconnected') {
|
||||
view.$('#controlbox-tabs').empty();
|
||||
view.renderLoginPanel();
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
afterReconnected: function () {
|
||||
this.__super__.afterReconnected.apply(this, arguments);
|
||||
var view = converse.chatboxviews.get('controlbox');
|
||||
if (view.model.get('connected')) {
|
||||
converse.chatboxviews.get("controlbox").onConnected();
|
||||
} else {
|
||||
view.model.set({connected:true});
|
||||
}
|
||||
},
|
||||
|
||||
_tearDown: function () {
|
||||
this.__super__._tearDown.apply(this, arguments);
|
||||
if (this.rosterview) {
|
||||
|
@ -809,6 +783,32 @@
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
var disconnect = function () {
|
||||
/* Upon disconnection, set connected to `false`, so that if
|
||||
* we reconnect,
|
||||
* "onConnected" will be called, to fetch the roster again and
|
||||
* to send out a presence stanza.
|
||||
*/
|
||||
var view = converse.chatboxviews.get('controlbox');
|
||||
view.model.set({connected:false});
|
||||
view.$('#controlbox-tabs').empty();
|
||||
view.renderLoginPanel();
|
||||
};
|
||||
converse.on('disconnected', disconnect);
|
||||
|
||||
var afterReconnected = function () {
|
||||
/* After reconnection makes sure the controlbox's is aware.
|
||||
*/
|
||||
var view = converse.chatboxviews.get('controlbox');
|
||||
if (view.model.get('connected')) {
|
||||
converse.chatboxviews.get("controlbox").onConnected();
|
||||
} else {
|
||||
view.model.set({connected:true});
|
||||
}
|
||||
};
|
||||
converse.on('reconnected', afterReconnected);
|
||||
|
||||
}
|
||||
});
|
||||
}));
|
||||
|
|
|
@ -1403,7 +1403,7 @@
|
|||
// Unfortunately this doesn't work (returns empty list)
|
||||
// var elements = stanza.querySelectorAll('x[xmlns="'+Strophe.NS.MUC_USER+'"]');
|
||||
var elements = _.chain(stanza.querySelectorAll('x')).filter(function (x) {
|
||||
return x.getAttribute('xmlns') == Strophe.NS.MUC_USER;
|
||||
return x.getAttribute('xmlns') === Strophe.NS.MUC_USER;
|
||||
}).value();
|
||||
|
||||
var notifications = _.map(
|
||||
|
|
Loading…
Reference in New Issue
Block a user