Commit 33d84a0c authored by JC Brand's avatar JC Brand

Store roster on converse obj.

Storing it on the rosterview causes race conditions.
parent ce0096de
...@@ -338,7 +338,7 @@ ...@@ -338,7 +338,7 @@
img_type = $vcard.find('TYPE').text(), img_type = $vcard.find('TYPE').text(),
url = $vcard.find('URL').text(); url = $vcard.find('URL').text();
if (jid) { if (jid) {
var contact = converse.rosterview.roster.get(jid); var contact = converse.roster.get(jid);
if (contact) { if (contact) {
fullname = _.isEmpty(fullname)? contact.get('fullname') || jid: fullname; fullname = _.isEmpty(fullname)? contact.get('fullname') || jid: fullname;
contact.save({ contact.save({
...@@ -357,7 +357,7 @@ ...@@ -357,7 +357,7 @@
jid, jid,
function (iq) { function (iq) {
// Error callback // Error callback
var contact = converse.rosterview.roster.get(jid); var contact = converse.roster.get(jid);
if (contact) { if (contact) {
contact.save({ contact.save({
'vcard_updated': moment().format() 'vcard_updated': moment().format()
...@@ -565,6 +565,7 @@ ...@@ -565,6 +565,7 @@
this.features = new this.Features(); this.features = new this.Features();
this.enableCarbons(); this.enableCarbons();
this.initStatus($.proxy(function () { this.initStatus($.proxy(function () {
this.roster = new converse.RosterContacts();
this.rosterview = new this.RosterView({model: new this.RosterGroups()}); this.rosterview = new this.RosterView({model: new this.RosterGroups()});
this.chatboxes.onConnected(); this.chatboxes.onConnected();
this.connection.roster.get(function () {}); this.connection.roster.get(function () {});
...@@ -1333,7 +1334,7 @@ ...@@ -1333,7 +1334,7 @@
updateVCard: function () { updateVCard: function () {
var jid = this.model.get('jid'), var jid = this.model.get('jid'),
contact = converse.rosterview.roster.get(jid); contact = converse.roster.get(jid);
if ((contact) && (!contact.get('vcard_updated'))) { if ((contact) && (!contact.get('vcard_updated'))) {
converse.getVCard( converse.getVCard(
jid, jid,
...@@ -2458,7 +2459,7 @@ ...@@ -2458,7 +2459,7 @@
resource = Strophe.getResourceFromJid(message_from); resource = Strophe.getResourceFromJid(message_from);
} }
chatbox = this.get(buddy_jid); chatbox = this.get(buddy_jid);
roster_item = converse.rosterview.roster.get(buddy_jid); roster_item = converse.roster.get(buddy_jid);
if (roster_item === undefined) { if (roster_item === undefined) {
// The buddy was likely removed // The buddy was likely removed
...@@ -2479,7 +2480,7 @@ ...@@ -2479,7 +2480,7 @@
}); });
} }
chatbox.receiveMessage($message); chatbox.receiveMessage($message);
converse.rosterview.roster.addResource(buddy_jid, resource); converse.roster.addResource(buddy_jid, resource);
converse.emit('message', message); converse.emit('message', message);
return true; return true;
} }
...@@ -2734,7 +2735,8 @@ ...@@ -2734,7 +2735,8 @@
}, },
updateUnreadMessagesCounter: function () { updateUnreadMessagesCounter: function () {
var ls = this.model.pluck('num_unread'), count = 0; var ls = this.model.pluck('num_unread'),
count = 0, i;
for (i=0; i<ls.length; i++) { count += ls[i]; } for (i=0; i<ls.length; i++) { count += ls[i]; }
this.toggleview.model.set({'num_unread': count}); this.toggleview.model.set({'num_unread': count});
this.render(); this.render();
...@@ -2932,6 +2934,9 @@ ...@@ -2932,6 +2934,9 @@
this.RosterContacts = Backbone.Collection.extend({ this.RosterContacts = Backbone.Collection.extend({
model: converse.RosterContact, model: converse.RosterContact,
browserStorage: new Backbone.BrowserStorage[converse.storage](
b64_sha1('converse.contacts-'+converse.bare_jid)),
comparator: function (contact1, contact2) { comparator: function (contact1, contact2) {
var name1 = contact1.get('fullname').toLowerCase(); var name1 = contact1.get('fullname').toLowerCase();
var status1 = contact1.get('chat_status') || 'offline'; var status1 = contact1.get('chat_status') || 'offline';
...@@ -3218,7 +3223,6 @@ ...@@ -3218,7 +3223,6 @@
description: DESC_GROUP_TOGGLE, description: DESC_GROUP_TOGGLE,
state: OPENED state: OPENED
}, attributes)) }, attributes))
// Collection of contacts belonging to this group. // Collection of contacts belonging to this group.
this.contacts = new converse.RosterContacts(); this.contacts = new converse.RosterContacts();
} }
...@@ -3238,7 +3242,7 @@ ...@@ -3238,7 +3242,7 @@
}, this); }, this);
this.model.contacts.on("destroy", this.onRemove, this); this.model.contacts.on("destroy", this.onRemove, this);
this.model.contacts.on("remove", this.onRemove, this); this.model.contacts.on("remove", this.onRemove, this);
converse.rosterview.roster.on('change:groups', this.onContactGroupChange, this); converse.roster.on('change:groups', this.onContactGroupChange, this);
}, },
render: function () { render: function () {
...@@ -3362,21 +3366,18 @@ ...@@ -3362,21 +3366,18 @@
id: 'converse-roster', id: 'converse-roster',
initialize: function () { initialize: function () {
this.roster = new converse.RosterContacts();
this.roster.browserStorage = new Backbone.BrowserStorage[converse.storage](
b64_sha1('converse.contacts-'+converse.bare_jid));
this.registerRosterHandler(); this.registerRosterHandler();
this.registerRosterXHandler(); this.registerRosterXHandler();
this.registerPresenceHandler(); this.registerPresenceHandler();
this.roster.on("add", this.onAdd, this); converse.roster.on("add", this.onAdd, this);
this.roster.on('change', this.onChange, this); converse.roster.on('change', this.onChange, this);
this.roster.on("remove", this.update, this); converse.roster.on("remove", this.update, this);
this.roster.on("destroy", this.update, this); converse.roster.on("destroy", this.update, this);
this.model.on("reset", this.reset, this); this.model.on("reset", this.reset, this);
this.render(); this.render();
this.model.fetch({add: true}); this.model.fetch({add: true});
this.roster.fetch({add: true}); converse.roster.fetch({add: true});
}, },
render: function () { render: function () {
...@@ -3387,7 +3388,7 @@ ...@@ -3387,7 +3388,7 @@
update: function () { update: function () {
// XXX: Is this still being used/valid? // XXX: Is this still being used/valid?
var $count = $('#online-count'); var $count = $('#online-count');
$count.text('('+this.roster.getNumOnlineContacts()+')'); $count.text('('+converse.roster.getNumOnlineContacts()+')');
if (!$count.is(':visible')) { if (!$count.is(':visible')) {
$count.show(); $count.show();
} }
...@@ -3395,7 +3396,7 @@ ...@@ -3395,7 +3396,7 @@
}, },
reset: function () { reset: function () {
this.roster.reset(); converse.roster.reset();
this.removeAll(); this.removeAll();
this.render().update(); this.render().update();
return this; return this;
...@@ -3404,20 +3405,20 @@ ...@@ -3404,20 +3405,20 @@
registerRosterHandler: function () { registerRosterHandler: function () {
// Register handlers that depend on the roster // Register handlers that depend on the roster
converse.connection.roster.registerCallback( converse.connection.roster.registerCallback(
$.proxy(this.roster.rosterHandler, this.roster), $.proxy(converse.roster.rosterHandler, converse.roster),
null, 'presence', null); null, 'presence', null);
}, },
registerRosterXHandler: function () { registerRosterXHandler: function () {
converse.connection.addHandler( converse.connection.addHandler(
$.proxy(this.roster.subscribeToSuggestedItems, this.roster), $.proxy(converse.roster.subscribeToSuggestedItems, converse.roster),
'http://jabber.org/protocol/rosterx', 'message', null); 'http://jabber.org/protocol/rosterx', 'message', null);
}, },
registerPresenceHandler: function () { registerPresenceHandler: function () {
converse.connection.addHandler( converse.connection.addHandler(
$.proxy(function (presence) { $.proxy(function (presence) {
this.roster.presenceHandler(presence); converse.roster.presenceHandler(presence);
return true; return true;
}, this), null, 'presence', null); }, this), null, 'presence', null);
}, },
...@@ -3475,7 +3476,7 @@ ...@@ -3475,7 +3476,7 @@
return view; return view;
} }
view = new converse.RosterGroupView({ view = new converse.RosterGroupView({
model: this.model.create({name: name, id: b64_sha1(name)}) model: this.model.create({name: name, id: b64_sha1(name)}),
}); });
this.add(name, view); this.add(name, view);
return this.positionGroup(view) return this.positionGroup(view)
......
...@@ -682,7 +682,7 @@ ...@@ -682,7 +682,7 @@
beforeEach(function () { beforeEach(function () {
utils.closeAllChatBoxes(); utils.closeAllChatBoxes();
utils.removeControlBox(); utils.removeControlBox();
converse.rosterview.roster.browserStorage._clear(); converse.roster.browserStorage._clear();
utils.initConverse(); utils.initConverse();
utils.createContacts(); utils.createContacts();
utils.openControlBox(); utils.openControlBox();
......
...@@ -158,7 +158,7 @@ ...@@ -158,7 +158,7 @@
_.each(_.keys(groups), $.proxy(function (name) { _.each(_.keys(groups), $.proxy(function (name) {
j = i; j = i;
for (i=j; i<j+groups[name]; i++) { for (i=j; i<j+groups[name]; i++) {
this.rosterview.roster.create({ this.roster.create({
jid: mock.cur_names[i].replace(/ /g,'.').toLowerCase() + '@localhost', jid: mock.cur_names[i].replace(/ /g,'.').toLowerCase() + '@localhost',
subscription: 'both', subscription: 'both',
ask: null, ask: null,
...@@ -196,7 +196,7 @@ ...@@ -196,7 +196,7 @@
converse.rosterview.render(); converse.rosterview.render();
var groups = ['colleagues', 'friends']; var groups = ['colleagues', 'friends'];
for (i=0; i<mock.cur_names.length; i++) { for (i=0; i<mock.cur_names.length; i++) {
this.rosterview.roster.create({ this.roster.create({
jid: mock.cur_names[i].replace(/ /g,'.').toLowerCase() + '@localhost', jid: mock.cur_names[i].replace(/ /g,'.').toLowerCase() + '@localhost',
subscription: 'both', subscription: 'both',
ask: null, ask: null,
...@@ -224,7 +224,7 @@ ...@@ -224,7 +224,7 @@
_.each(_.keys(groups), $.proxy(function (name) { _.each(_.keys(groups), $.proxy(function (name) {
j = i; j = i;
for (i=j; i<j+groups[name]; i++) { for (i=j; i<j+groups[name]; i++) {
this.rosterview.roster.create({ this.roster.create({
jid: mock.cur_names[i].replace(/ /g,'.').toLowerCase() + '@localhost', jid: mock.cur_names[i].replace(/ /g,'.').toLowerCase() + '@localhost',
subscription: 'both', subscription: 'both',
ask: null, ask: null,
...@@ -266,7 +266,7 @@ ...@@ -266,7 +266,7 @@
spyOn(converse, 'emit'); spyOn(converse, 'emit');
spyOn(this.rosterview, 'update').andCallThrough(); spyOn(this.rosterview, 'update').andCallThrough();
runs($.proxy(function () { runs($.proxy(function () {
this.rosterview.roster.create({ this.roster.create({
jid: mock.pend_names[0].replace(/ /g,'.').toLowerCase() + '@localhost', jid: mock.pend_names[0].replace(/ /g,'.').toLowerCase() + '@localhost',
subscription: 'none', subscription: 'none',
ask: 'subscribe', ask: 'subscribe',
...@@ -305,7 +305,7 @@ ...@@ -305,7 +305,7 @@
var name = mock.pend_names[0]; var name = mock.pend_names[0];
_clearContacts(); _clearContacts();
spyOn(window, 'confirm').andReturn(true); spyOn(window, 'confirm').andReturn(true);
this.rosterview.roster.create({ this.roster.create({
jid: name.replace(/ /g,'.').toLowerCase() + '@localhost', jid: name.replace(/ /g,'.').toLowerCase() + '@localhost',
subscription: 'none', subscription: 'none',
ask: 'subscribe', ask: 'subscribe',
...@@ -339,7 +339,7 @@ ...@@ -339,7 +339,7 @@
spyOn(this.rosterview, 'update').andCallThrough(); spyOn(this.rosterview, 'update').andCallThrough();
for (i=0; i<mock.pend_names.length; i++) { for (i=0; i<mock.pend_names.length; i++) {
is_last = i===(mock.pend_names.length-1); is_last = i===(mock.pend_names.length-1);
this.rosterview.roster.create({ this.roster.create({
jid: mock.pend_names[i].replace(/ /g,'.').toLowerCase() + '@localhost', jid: mock.pend_names[i].replace(/ /g,'.').toLowerCase() + '@localhost',
subscription: 'none', subscription: 'none',
ask: 'subscribe', ask: 'subscribe',
...@@ -377,7 +377,7 @@ ...@@ -377,7 +377,7 @@
spyOn(converse, 'emit'); spyOn(converse, 'emit');
spyOn(this.rosterview, 'update').andCallThrough(); spyOn(this.rosterview, 'update').andCallThrough();
for (i=0; i<mock.cur_names.length; i++) { for (i=0; i<mock.cur_names.length; i++) {
this.rosterview.roster.create({ this.roster.create({
jid: mock.cur_names[i].replace(/ /g,'.').toLowerCase() + '@localhost', jid: mock.cur_names[i].replace(/ /g,'.').toLowerCase() + '@localhost',
subscription: 'both', subscription: 'both',
ask: null, ask: null,
...@@ -416,7 +416,7 @@ ...@@ -416,7 +416,7 @@
var name = mock.cur_names[0]; var name = mock.cur_names[0];
_clearContacts(); _clearContacts();
spyOn(window, 'confirm').andReturn(true); spyOn(window, 'confirm').andReturn(true);
this.rosterview.roster.create({ this.roster.create({
jid: name.replace(/ /g,'.').toLowerCase() + '@localhost', jid: name.replace(/ /g,'.').toLowerCase() + '@localhost',
subscription: 'both', subscription: 'both',
ask: null, ask: null,
...@@ -437,7 +437,7 @@ ...@@ -437,7 +437,7 @@
spyOn(this.rosterview, 'update').andCallThrough(); spyOn(this.rosterview, 'update').andCallThrough();
for (i=0; i<mock.cur_names.length; i++) { for (i=0; i<mock.cur_names.length; i++) {
jid = mock.cur_names[i].replace(/ /g,'.').toLowerCase() + '@localhost'; jid = mock.cur_names[i].replace(/ /g,'.').toLowerCase() + '@localhost';
this.rosterview.roster.get(jid).set('chat_status', 'online'); this.roster.get(jid).set('chat_status', 'online');
expect(this.rosterview.update).toHaveBeenCalled(); expect(this.rosterview.update).toHaveBeenCalled();
// Check that they are sorted alphabetically // Check that they are sorted alphabetically
t = this.rosterview.$el.find('dt.roster-group').siblings('dd.current-xmpp-contact.online').find('a.open-chat').text(); t = this.rosterview.$el.find('dt.roster-group').siblings('dd.current-xmpp-contact.online').find('a.open-chat').text();
...@@ -452,7 +452,7 @@ ...@@ -452,7 +452,7 @@
spyOn(this.rosterview, 'update').andCallThrough(); spyOn(this.rosterview, 'update').andCallThrough();
for (i=0; i<mock.cur_names.length; i++) { for (i=0; i<mock.cur_names.length; i++) {
jid = mock.cur_names[i].replace(/ /g,'.').toLowerCase() + '@localhost'; jid = mock.cur_names[i].replace(/ /g,'.').toLowerCase() + '@localhost';
this.rosterview.roster.get(jid).set('chat_status', 'dnd'); this.roster.get(jid).set('chat_status', 'dnd');
expect(this.rosterview.update).toHaveBeenCalled(); expect(this.rosterview.update).toHaveBeenCalled();
// Check that they are sorted alphabetically // Check that they are sorted alphabetically
t = this.rosterview.$el.find('dt.roster-group').siblings('dd.current-xmpp-contact.dnd').find('a.open-chat').text(); t = this.rosterview.$el.find('dt.roster-group').siblings('dd.current-xmpp-contact.dnd').find('a.open-chat').text();
...@@ -467,7 +467,7 @@ ...@@ -467,7 +467,7 @@
spyOn(this.rosterview, 'update').andCallThrough(); spyOn(this.rosterview, 'update').andCallThrough();
for (i=0; i<mock.cur_names.length; i++) { for (i=0; i<mock.cur_names.length; i++) {
jid = mock.cur_names[i].replace(/ /g,'.').toLowerCase() + '@localhost'; jid = mock.cur_names[i].replace(/ /g,'.').toLowerCase() + '@localhost';
this.rosterview.roster.get(jid).set('chat_status', 'away'); this.roster.get(jid).set('chat_status', 'away');
expect(this.rosterview.update).toHaveBeenCalled(); expect(this.rosterview.update).toHaveBeenCalled();
// Check that they are sorted alphabetically // Check that they are sorted alphabetically
t = this.rosterview.$el.find('dt.roster-group').siblings('dd.current-xmpp-contact.away').find('a.open-chat').text(); t = this.rosterview.$el.find('dt.roster-group').siblings('dd.current-xmpp-contact.away').find('a.open-chat').text();
...@@ -482,7 +482,7 @@ ...@@ -482,7 +482,7 @@
spyOn(this.rosterview, 'update').andCallThrough(); spyOn(this.rosterview, 'update').andCallThrough();
for (i=0; i<mock.cur_names.length; i++) { for (i=0; i<mock.cur_names.length; i++) {
jid = mock.cur_names[i].replace(/ /g,'.').toLowerCase() + '@localhost'; jid = mock.cur_names[i].replace(/ /g,'.').toLowerCase() + '@localhost';
this.rosterview.roster.get(jid).set('chat_status', 'xa'); this.roster.get(jid).set('chat_status', 'xa');
expect(this.rosterview.update).toHaveBeenCalled(); expect(this.rosterview.update).toHaveBeenCalled();
// Check that they are sorted alphabetically // Check that they are sorted alphabetically
t = this.rosterview.$el.find('dt.roster-group').siblings('dd.current-xmpp-contact.xa').find('a.open-chat').text(); t = this.rosterview.$el.find('dt.roster-group').siblings('dd.current-xmpp-contact.xa').find('a.open-chat').text();
...@@ -497,7 +497,7 @@ ...@@ -497,7 +497,7 @@
spyOn(this.rosterview, 'update').andCallThrough(); spyOn(this.rosterview, 'update').andCallThrough();
for (i=0; i<mock.cur_names.length; i++) { for (i=0; i<mock.cur_names.length; i++) {
jid = mock.cur_names[i].replace(/ /g,'.').toLowerCase() + '@localhost'; jid = mock.cur_names[i].replace(/ /g,'.').toLowerCase() + '@localhost';
this.rosterview.roster.get(jid).set('chat_status', 'unavailable'); this.roster.get(jid).set('chat_status', 'unavailable');
expect(this.rosterview.update).toHaveBeenCalled(); expect(this.rosterview.update).toHaveBeenCalled();
// Check that they are sorted alphabetically // Check that they are sorted alphabetically
t = this.rosterview.$el.find('dt.roster-group').siblings('dd.current-xmpp-contact.unavailable').find('a.open-chat').text(); t = this.rosterview.$el.find('dt.roster-group').siblings('dd.current-xmpp-contact.unavailable').find('a.open-chat').text();
...@@ -510,23 +510,23 @@ ...@@ -510,23 +510,23 @@
var i; var i;
for (i=0; i<3; i++) { for (i=0; i<3; i++) {
jid = mock.cur_names[i].replace(/ /g,'.').toLowerCase() + '@localhost'; jid = mock.cur_names[i].replace(/ /g,'.').toLowerCase() + '@localhost';
this.rosterview.roster.get(jid).set('chat_status', 'online'); this.roster.get(jid).set('chat_status', 'online');
} }
for (i=3; i<6; i++) { for (i=3; i<6; i++) {
jid = mock.cur_names[i].replace(/ /g,'.').toLowerCase() + '@localhost'; jid = mock.cur_names[i].replace(/ /g,'.').toLowerCase() + '@localhost';
this.rosterview.roster.get(jid).set('chat_status', 'dnd'); this.roster.get(jid).set('chat_status', 'dnd');
} }
for (i=6; i<9; i++) { for (i=6; i<9; i++) {
jid = mock.cur_names[i].replace(/ /g,'.').toLowerCase() + '@localhost'; jid = mock.cur_names[i].replace(/ /g,'.').toLowerCase() + '@localhost';
this.rosterview.roster.get(jid).set('chat_status', 'away'); this.roster.get(jid).set('chat_status', 'away');
} }
for (i=9; i<12; i++) { for (i=9; i<12; i++) {
jid = mock.cur_names[i].replace(/ /g,'.').toLowerCase() + '@localhost'; jid = mock.cur_names[i].replace(/ /g,'.').toLowerCase() + '@localhost';
this.rosterview.roster.get(jid).set('chat_status', 'xa'); this.roster.get(jid).set('chat_status', 'xa');
} }
for (i=12; i<15; i++) { for (i=12; i<15; i++) {
jid = mock.cur_names[i].replace(/ /g,'.').toLowerCase() + '@localhost'; jid = mock.cur_names[i].replace(/ /g,'.').toLowerCase() + '@localhost';
this.rosterview.roster.get(jid).set('chat_status', 'unavailable'); this.roster.get(jid).set('chat_status', 'unavailable');
} }
var contacts = this.rosterview.$el.find('dd.current-xmpp-contact'); var contacts = this.rosterview.$el.find('dd.current-xmpp-contact');
...@@ -577,7 +577,7 @@ ...@@ -577,7 +577,7 @@
} }
}; };
for (i=0; i<mock.req_names.length; i++) { for (i=0; i<mock.req_names.length; i++) {
this.rosterview.roster.create({ this.roster.create({
jid: mock.req_names[i].replace(/ /g,'.').toLowerCase() + '@localhost', jid: mock.req_names[i].replace(/ /g,'.').toLowerCase() + '@localhost',
subscription: 'none', subscription: 'none',
ask: null, ask: null,
...@@ -601,7 +601,7 @@ ...@@ -601,7 +601,7 @@
converse.rosterview.model.reset(); // We want to manually create users so that we can spy converse.rosterview.model.reset(); // We want to manually create users so that we can spy
var name = mock.req_names[0]; var name = mock.req_names[0];
spyOn(window, 'confirm').andReturn(true); spyOn(window, 'confirm').andReturn(true);
this.rosterview.roster.create({ this.roster.create({
jid: name.replace(/ /g,'.').toLowerCase() + '@localhost', jid: name.replace(/ /g,'.').toLowerCase() + '@localhost',
subscription: 'none', subscription: 'none',
ask: null, ask: null,
...@@ -650,7 +650,7 @@ ...@@ -650,7 +650,7 @@
expect(window.confirm).toHaveBeenCalled(); expect(window.confirm).toHaveBeenCalled();
expect(this.connection.roster.unauthorize).toHaveBeenCalled(); expect(this.connection.roster.unauthorize).toHaveBeenCalled();
// There should now be one less contact // There should now be one less contact
expect(this.rosterview.roster.length).toEqual(mock.req_names.length-1); expect(this.roster.length).toEqual(mock.req_names.length-1);
}, converse)); }, converse));
}, converse)); }, converse));
...@@ -664,11 +664,11 @@ ...@@ -664,11 +664,11 @@
it("are saved to, and can be retrieved from, browserStorage", $.proxy(function () { it("are saved to, and can be retrieved from, browserStorage", $.proxy(function () {
var new_attrs, old_attrs, attrs, old_roster; var new_attrs, old_attrs, attrs, old_roster;
var num_contacts = this.rosterview.roster.length; var num_contacts = this.roster.length;
new_roster = new this.RosterContacts(); new_roster = new this.RosterContacts();
// Roster items are yet to be fetched from browserStorage // Roster items are yet to be fetched from browserStorage
expect(new_roster.length).toEqual(0); expect(new_roster.length).toEqual(0);
new_roster.browserStorage = this.rosterview.roster.browserStorage; new_roster.browserStorage = this.roster.browserStorage;
new_roster.fetch(); new_roster.fetch();
expect(new_roster.length).toEqual(num_contacts); expect(new_roster.length).toEqual(num_contacts);
// Check that the roster items retrieved from browserStorage // Check that the roster items retrieved from browserStorage
...@@ -676,7 +676,7 @@ ...@@ -676,7 +676,7 @@
attrs = ['jid', 'fullname', 'subscription', 'ask']; attrs = ['jid', 'fullname', 'subscription', 'ask'];
for (i=0; i<attrs.length; i++) { for (i=0; i<attrs.length; i++) {
new_attrs = _.pluck(_.pluck(new_roster.models, 'attributes'), attrs[i]); new_attrs = _.pluck(_.pluck(new_roster.models, 'attributes'), attrs[i]);
old_attrs = _.pluck(_.pluck(this.rosterview.roster.models, 'attributes'), attrs[i]); old_attrs = _.pluck(_.pluck(this.roster.models, 'attributes'), attrs[i]);
// Roster items in storage are not necessarily sorted, // Roster items in storage are not necessarily sorted,
// so we have to sort them here to do a proper // so we have to sort them here to do a proper
// comparison // comparison
...@@ -691,7 +691,7 @@ ...@@ -691,7 +691,7 @@
// we make some online now // we make some online now
for (i=0; i<5; i++) { for (i=0; i<5; i++) {
jid = mock.cur_names[i].replace(/ /g,'.').toLowerCase() + '@localhost'; jid = mock.cur_names[i].replace(/ /g,'.').toLowerCase() + '@localhost';
this.rosterview.roster.get(jid).set('chat_status', 'online'); this.roster.get(jid).set('chat_status', 'online');
} }
}, converse)); }, converse));
}, converse)); }, converse));
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
runs(function () { runs(function () {
utils.closeAllChatBoxes(); utils.closeAllChatBoxes();
utils.removeControlBox(); utils.removeControlBox();
converse.rosterview.roster.browserStorage._clear(); converse.roster.browserStorage._clear();
utils.initConverse(); utils.initConverse();
utils.createContacts(); utils.createContacts();
utils.openControlBox(); utils.openControlBox();
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
}; };
utils.initRoster = function () { utils.initRoster = function () {
converse.rosterview.roster.browserStorage._clear(); converse.roster.browserStorage._clear();
converse.initRoster(); converse.initRoster();
}; };
...@@ -80,13 +80,13 @@ ...@@ -80,13 +80,13 @@
var i = 0, jid, views = []; var i = 0, jid, views = [];
for (i; i<amount; i++) { for (i; i<amount; i++) {
jid = mock.cur_names[i].replace(/ /g,'.').toLowerCase() + '@localhost'; jid = mock.cur_names[i].replace(/ /g,'.').toLowerCase() + '@localhost';
views[i] = converse.rosterview.roster.get(jid).trigger("open"); views[i] = converse.roster.get(jid).trigger("open");
} }
return views; return views;
}; };
utils.openChatBoxFor = function (jid) { utils.openChatBoxFor = function (jid) {
return converse.rosterview.roster.get(jid).trigger("open"); return converse.roster.get(jid).trigger("open");
}; };
utils.removeRosterContacts = function () { utils.removeRosterContacts = function () {
...@@ -134,7 +134,7 @@ ...@@ -134,7 +134,7 @@
ask = null; ask = null;
} }
for (i=0; i<names.length; i++) { for (i=0; i<names.length; i++) {
converse.rosterview.roster.create({ converse.roster.create({
ask: ask, ask: ask,
fullname: names[i], fullname: names[i],
is_last: i===(names.length-1), is_last: i===(names.length-1),
......
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