Commit 776f49d5 authored by JC Brand's avatar JC Brand

Bugfix. Don't remove model, simply remove view

Otherwise the model gets removed mid-creation, which causes the
`url required` error from Backbone.
parent 7e94f3c6
......@@ -115,10 +115,7 @@
},
isOnlyChatStateNotification () {
return this.get('chat_state') &&
!this.get('oob_url') &&
!this.get('file') &&
!this.get('message');
return u.isOnlyChatStateNotification(this);
},
getDisplayName () {
......@@ -451,7 +448,12 @@
/* Create a Backbone.Message object inside this chat box
* based on the identified message stanza.
*/
return this.messages.create(this.getMessageAttributesFromStanza.apply(this, arguments));
const attrs = this.getMessageAttributesFromStanza.apply(this, arguments)
if (u.isOnlyChatStateNotification(attrs)) {
return;
} else {
return this.messages.create(attrs);
}
},
newMessageWillBeHidden () {
......
......@@ -160,9 +160,6 @@
},
renderChatStateNotification () {
if (this.model.get('delayed')) {
return this.model.destroy();
}
let text;
const from = this.model.get('from'),
name = this.model.getDisplayName();
......
......@@ -13,6 +13,7 @@
"sizzle",
"es6-promise",
"lodash.noconflict",
"backbone",
"strophe",
"uri",
"tpl!audio",
......@@ -46,6 +47,7 @@
sizzle,
Promise,
_,
Backbone,
Strophe,
URI,
tpl_audio,
......@@ -488,6 +490,16 @@
}
};
u.isOnlyChatStateNotification = function (attrs) {
if (attrs instanceof Backbone.Model) {
attrs = attrs.attributes;
}
return attrs['chat_state'] &&
!attrs['oob_url'] &&
!attrs['file'] &&
!attrs['message'];
};
u.isOTRMessage = function (message) {
var body = message.querySelector('body'),
text = (!_.isNull(body) ? body.textContent: undefined);
......
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