Commit be761562 authored by JC Brand's avatar JC Brand

All tests pass \o/

parent cfa55896
......@@ -3237,6 +3237,11 @@
},
initialize: function () {
/* If initialize ever gets called again, event listeners will
* be registered twice. So we turn them off first.
* Currently only an issue in tests.
*/
this.model.off();
this.model.on("add", this.onAdd, this);
this.model.on('change', this.onChange, this);
this.model.on("remove", this.removeRosterItemView, this);
......@@ -3271,7 +3276,7 @@
},
onAdd: function (item) {
this.addRosterItemView(item).addRosterItem(item).updateRoster();
this.addRosterItem(item).updateRoster();
if (item.get('is_last')) {
this.sortRoster().showRoster();
}
......@@ -3316,12 +3321,6 @@
return this;
},
addRosterItemView: function (item) {
var view = new converse.RosterItemView({model: item});
this.add(item.id, view);
return this;
},
removeAllRosterItemViews: function () {
this.removeAll();
this.updateRoster();
......@@ -3363,14 +3362,11 @@
},
addRosterItem: function (item) {
var view = new converse.RosterItemView({model: item});
this.add(item.id, view);
if ((converse.show_only_online_users) && (item.get('chat_status') !== 'online')) {
return this;
}
var view = this.get(item.id);
if (!view) {
converse.log("renderRosterItem called with item that doesn't have a view", "error");
return this;
}
view.render()
var $el = this.getRosterElement();
if (view.$el.hasClass('current-xmpp-contact')) {
......
......@@ -132,7 +132,7 @@
function _clearContacts () {
utils.clearBrowserStorage();
converse.rosterview.model.reset();
converse.rosterview.initialize();
converse.rosterview.initialize(); // Register new listeners and document fragment
};
function _addContacts () {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment