Bugfix. Don't remove model, simply remove view
Otherwise the model gets removed mid-creation, which causes the `url required` error from Backbone.
This commit is contained in:
parent
7e94f3c691
commit
776f49d5c3
@ -115,10 +115,7 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
isOnlyChatStateNotification () {
|
isOnlyChatStateNotification () {
|
||||||
return this.get('chat_state') &&
|
return u.isOnlyChatStateNotification(this);
|
||||||
!this.get('oob_url') &&
|
|
||||||
!this.get('file') &&
|
|
||||||
!this.get('message');
|
|
||||||
},
|
},
|
||||||
|
|
||||||
getDisplayName () {
|
getDisplayName () {
|
||||||
@ -451,7 +448,12 @@
|
|||||||
/* Create a Backbone.Message object inside this chat box
|
/* Create a Backbone.Message object inside this chat box
|
||||||
* based on the identified message stanza.
|
* 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 () {
|
newMessageWillBeHidden () {
|
||||||
|
@ -160,9 +160,6 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
renderChatStateNotification () {
|
renderChatStateNotification () {
|
||||||
if (this.model.get('delayed')) {
|
|
||||||
return this.model.destroy();
|
|
||||||
}
|
|
||||||
let text;
|
let text;
|
||||||
const from = this.model.get('from'),
|
const from = this.model.get('from'),
|
||||||
name = this.model.getDisplayName();
|
name = this.model.getDisplayName();
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
"sizzle",
|
"sizzle",
|
||||||
"es6-promise",
|
"es6-promise",
|
||||||
"lodash.noconflict",
|
"lodash.noconflict",
|
||||||
|
"backbone",
|
||||||
"strophe",
|
"strophe",
|
||||||
"uri",
|
"uri",
|
||||||
"tpl!audio",
|
"tpl!audio",
|
||||||
@ -46,6 +47,7 @@
|
|||||||
sizzle,
|
sizzle,
|
||||||
Promise,
|
Promise,
|
||||||
_,
|
_,
|
||||||
|
Backbone,
|
||||||
Strophe,
|
Strophe,
|
||||||
URI,
|
URI,
|
||||||
tpl_audio,
|
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) {
|
u.isOTRMessage = function (message) {
|
||||||
var body = message.querySelector('body'),
|
var body = message.querySelector('body'),
|
||||||
text = (!_.isNull(body) ? body.textContent: undefined);
|
text = (!_.isNull(body) ? body.textContent: undefined);
|
||||||
|
Loading…
Reference in New Issue
Block a user