diff --git a/converse.js b/converse.js index b80a5aca0..92fbdc468 100644 --- a/converse.js +++ b/converse.js @@ -3223,6 +3223,7 @@ this.model.on("remove", function (item) { this.removeRosterItemView(item); }, this); this.model.on("destroy", function (item) { this.removeRosterItemView(item); }, this); + this.model.on("reset", function () { this.removeAllRosterItemViewss(); }, this); var roster_markup = converse.templates.contacts({ 'label_contacts': __('My contacts') @@ -3263,6 +3264,12 @@ return this; }, + removeAllRosterItemViewss: function () { + var views = this.removeAll(); + this.render(); + return this; + }, + removeRosterItemView: function (item) { if (this.get(item.id)) { this.get(item.id).remove(); diff --git a/spec/chatbox.js b/spec/chatbox.js index a07151555..bb351b3c6 100644 --- a/spec/chatbox.js +++ b/spec/chatbox.js @@ -32,7 +32,7 @@ var online_contacts = this.rosterview.$el.find('dt#xmpp-contacts').siblings('dd.current-xmpp-contact').find('a.open-chat'); for (i=0; i:)', ':S', ':\\', '>:(', ':(', ':O', '(^.^)b', '<3']; @@ -651,7 +651,7 @@ }, converse)); it("will have properly escaped URLs", $.proxy(function () { - var contact_jid = mock.cur_names[0].replace(' ','.').toLowerCase() + '@localhost'; + var contact_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost'; utils.openChatBoxFor(contact_jid); var view = this.chatboxviews.get(contact_jid); spyOn(view, 'sendMessage').andCallThrough(); @@ -741,7 +741,7 @@ spyOn(converse, 'incrementMsgCounter').andCallThrough(); $(window).trigger('blur'); var message = 'This message will increment the message counter'; - var sender_jid = mock.cur_names[0].replace(' ','.').toLowerCase() + '@localhost'; + var sender_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost'; msg = $msg({ from: sender_jid, to: this.connection.jid, @@ -772,7 +772,7 @@ spyOn(converse, 'incrementMsgCounter').andCallThrough(); $(window).trigger('focus'); var message = 'This message will not increment the message counter'; - var sender_jid = mock.cur_names[0].replace(' ','.').toLowerCase() + '@localhost'; + var sender_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost'; msg = $msg({ from: sender_jid, to: this.connection.jid, diff --git a/spec/controlbox.js b/spec/controlbox.js index 36a590b2b..4fd66540c 100644 --- a/spec/controlbox.js +++ b/spec/controlbox.js @@ -205,7 +205,7 @@ beforeEach($.proxy(function () { runs(function () { converse.rosterview.model.reset(); - converse.rosterview.render(); + utils.createCurrentContacts(); }); waits(50); runs(function () { @@ -218,16 +218,18 @@ }, converse)); it("do not have a heading if there aren't any", $.proxy(function () { + converse.rosterview.model.reset(); expect(this.rosterview.$el.find('dt#xmpp-contacts').css('display')).toEqual('none'); }, converse)); it("can be added to the roster and they will be sorted alphabetically", $.proxy(function () { var i, t; + converse.rosterview.model.reset(); spyOn(converse, 'emit'); spyOn(this.rosterview, 'render').andCallThrough(); for (i=0; i