Commit d8d1c283 authored by JC Brand's avatar JC Brand

Let the RosterView render and populate itself

instead of having the ControlBoxView do it. This provides for cleaner
separation between the two plugins.
parent 70304952
...@@ -216,7 +216,7 @@ ...@@ -216,7 +216,7 @@
this.model.on('change:closed', this.ensureClosedState, this); this.model.on('change:closed', this.ensureClosedState, this);
this.render(); this.render();
if (this.model.get('connected')) { if (this.model.get('connected')) {
this.initRoster(); this.insertRoster();
} }
if (typeof this.model.get('closed')==='undefined') { if (typeof this.model.get('closed')==='undefined') {
this.model.set('closed', !converse.show_controlbox_by_default); this.model.set('closed', !converse.show_controlbox_by_default);
...@@ -252,20 +252,14 @@ ...@@ -252,20 +252,14 @@
onConnected: function () { onConnected: function () {
if (this.model.get('connected')) { if (this.model.get('connected')) {
this.render().initRoster(); this.render().insertRoster();
} }
}, },
initRoster: function () { insertRoster: function () {
/* We initialize the roster, which will appear inside the /* Place the rosterview inside the "Contacts" panel.
* Contacts Panel.
*/ */
converse.rosterview = new converse.RosterView({model: converse.rostergroups});
this.contactspanel.$el.append(converse.rosterview.$el); this.contactspanel.$el.append(converse.rosterview.$el);
converse.rosterview.render().populate().then(function () {
converse.rosterview.update();
converse.sendInitialPresence();
});
return this; return this;
}, },
......
...@@ -31,6 +31,20 @@ ...@@ -31,6 +31,20 @@
this.__super__.afterReconnected.apply(this, arguments); this.__super__.afterReconnected.apply(this, arguments);
}, },
initRoster: function () {
/* Create an instance of RosterView once the RosterGroups
* collection has been created (in converse-core.js)
*/
this.__super__.initRoster.apply(this, arguments);
converse.rosterview = new converse.RosterView({
'model': converse.rostergroups
});
converse.rosterview.render().populate().then(function () {
converse.rosterview.update();
converse.sendInitialPresence();
});
},
RosterGroups: { RosterGroups: {
comparator: function () { comparator: function () {
// RosterGroupsComparator only gets set later (once i18n is // RosterGroupsComparator only gets set later (once i18n is
......
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