Avoid trying to retrieve non-existing models. fixes #415

This commit is contained in:
JC Brand 2015-05-31 14:38:50 +02:00
parent e3f20bf1ad
commit bf61122805
2 changed files with 9 additions and 6 deletions

View File

@ -3411,17 +3411,19 @@
},
closeAllChatBoxes: function (include_controlbox) {
var i, chatbox;
// TODO: once Backbone.Overview has been refactored, we should
// be able to call .each on the views themselves.
this.model.each($.proxy(function (model) {
var ids = [];
this.model.each(function (model) {
var id = model.get('id');
if (include_controlbox || id !== 'controlbox') {
if (this.get(id)) { // Should always resolve, but shit happens
this.get(id).close();
}
ids.push(id);
}
}, this));
});
ids.forEach(function(id) {
var chatbox = this.get(id);
if (chatbox) { chatbox.close(); }
}, this);
return this;
},

View File

@ -9,6 +9,7 @@ Changelog
* Bugfix. clearSessions during unload event would throw an error when not logged in. [gbonvehi]
* Bugfix. wrong callback argument mapping in XmppStatus initialize: fullname is null [thierrytiti]
* #389 Allow login panel placeholders and roster item 'Name' translations. [gbonvehi]
* #415 closeAllChatBoxes is giving ReferenceError when 2 chats are open [nevcos, jcbrand]
* Add placeholder for "Insert a smiley" translation [thierrytiti]
* Updated French translation [thierrytiti]
* CSS fix: position and width of the div #conversejs [thierrytiti]