Commit d27c69d7 authored by JC Brand's avatar JC Brand

Set up the roster earlier

and do the fetching and sorting when the view is initialized
parent d985b7ae
...@@ -717,7 +717,7 @@ ...@@ -717,7 +717,7 @@
// Override the one in ChatBoxView // Override the one in ChatBoxView
this.model.on('change', $.proxy(function (item, changed) { this.model.on('change', $.proxy(function (item, changed) {
if (_.has(item.changed, 'connected')) { if (_.has(item.changed, 'connected')) {
this.render().setUpRoster(); this.render().appendRoster();
} }
if (_.has(item.changed, 'visible')) { if (_.has(item.changed, 'visible')) {
if (item.changed.visible === true) { if (item.changed.visible === true) {
...@@ -737,17 +737,8 @@ ...@@ -737,17 +737,8 @@
} }
}, },
setUpRoster: function () { appendRoster: function () {
if (xmppchat.roster) {
return;
}
xmppchat.roster = new xmppchat.RosterItems();
xmppchat.roster.localStorage = new Backbone.LocalStorage(
hex_sha1('converse.rosteritems-'+xmppchat.connection.bare_jid));
xmppchat.rosterview = new xmppchat.RosterView({'model':xmppchat.roster});
xmppchat.rosterview.$el.appendTo(this.contactspanel.$el); xmppchat.rosterview.$el.appendTo(this.contactspanel.$el);
xmppchat.roster.fetch({add: true}); // Get the cached roster items from localstorage
xmppchat.rosterview.initialSort();
}, },
template: _.template( template: _.template(
...@@ -1635,6 +1626,8 @@ ...@@ -1635,6 +1626,8 @@
}, this); }, this);
this.$el.hide().html(this.template()); this.$el.hide().html(this.template());
this.model.fetch({add: true}); // Get the cached roster items from localstorage
this.initialSort();
}, },
template: _.template('<dt id="xmpp-contact-requests">Contact requests</dt>' + template: _.template('<dt id="xmpp-contact-requests">Contact requests</dt>' +
...@@ -2016,6 +2009,12 @@ ...@@ -2016,6 +2009,12 @@
this.connection.domain = Strophe.getDomainFromJid(this.connection.jid); this.connection.domain = Strophe.getDomainFromJid(this.connection.jid);
this.connection.muc_domain = 'conference.' + this.connection.domain; this.connection.muc_domain = 'conference.' + this.connection.domain;
// Set up the roster
this.roster = new this.RosterItems();
this.roster.localStorage = new Backbone.LocalStorage(
hex_sha1('converse.rosteritems-'+this.connection.bare_jid));
this.rosterview = new this.RosterView({'model':this.roster});
this.xmppstatus = new this.XMPPStatus(); this.xmppstatus = new this.XMPPStatus();
this.chatboxes.onConnected(); this.chatboxes.onConnected();
......
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