|
@@ -3237,6 +3237,11 @@
|
|
},
|
|
},
|
|
|
|
|
|
initialize: function () {
|
|
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("add", this.onAdd, this);
|
|
this.model.on('change', this.onChange, this);
|
|
this.model.on('change', this.onChange, this);
|
|
this.model.on("remove", this.removeRosterItemView, this);
|
|
this.model.on("remove", this.removeRosterItemView, this);
|
|
@@ -3271,7 +3276,7 @@
|
|
},
|
|
},
|
|
|
|
|
|
onAdd: function (item) {
|
|
onAdd: function (item) {
|
|
- this.addRosterItemView(item).addRosterItem(item).updateRoster();
|
|
|
|
|
|
+ this.addRosterItem(item).updateRoster();
|
|
if (item.get('is_last')) {
|
|
if (item.get('is_last')) {
|
|
this.sortRoster().showRoster();
|
|
this.sortRoster().showRoster();
|
|
}
|
|
}
|
|
@@ -3316,12 +3321,6 @@
|
|
return this;
|
|
return this;
|
|
},
|
|
},
|
|
|
|
|
|
- addRosterItemView: function (item) {
|
|
|
|
- var view = new converse.RosterItemView({model: item});
|
|
|
|
- this.add(item.id, view);
|
|
|
|
- return this;
|
|
|
|
- },
|
|
|
|
-
|
|
|
|
removeAllRosterItemViews: function () {
|
|
removeAllRosterItemViews: function () {
|
|
this.removeAll();
|
|
this.removeAll();
|
|
this.updateRoster();
|
|
this.updateRoster();
|
|
@@ -3363,14 +3362,11 @@
|
|
},
|
|
},
|
|
|
|
|
|
addRosterItem: function (item) {
|
|
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')) {
|
|
if ((converse.show_only_online_users) && (item.get('chat_status') !== 'online')) {
|
|
return this;
|
|
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()
|
|
view.render()
|
|
var $el = this.getRosterElement();
|
|
var $el = this.getRosterElement();
|
|
if (view.$el.hasClass('current-xmpp-contact')) {
|
|
if (view.$el.hasClass('current-xmpp-contact')) {
|