Fixes #1668. MUC MAM blocked by "info" messages

This commit is contained in:
JC Brand 2019-08-06 23:29:56 +02:00
parent c9830c91b2
commit 5cb5ec4640
3 changed files with 13 additions and 10 deletions

View File

@ -395,6 +395,15 @@ converse.plugins.add('converse-chatboxes', {
}
},
getMostRecentMessage () {
for (var i=this.messages.length-1; i>=0; i--) {
const message = this.messages.at(i);
if (message.get('type') === this.get('message_type')) {
return message;
}
}
},
getUpdatedMessageAttributes (message, stanza) {
// Overridden in converse-muc and converse-mam
return {};

View File

@ -73,17 +73,16 @@ converse.plugins.add('converse-mam', {
if (this.disable_mam) {
return;
}
const most_recent_msg = u.getMostRecentMessage(this);
if (!most_recent_msg) {
this.fetchArchivedMessages({'before': ''});
} else {
const most_recent_msg = this.getMostRecentMessage();
if (most_recent_msg) {
const stanza_id = most_recent_msg.get(`stanza_id ${this.get('jid')}`);
if (stanza_id) {
this.fetchArchivedMessages({'after': stanza_id}, 'forwards');
} else {
this.fetchArchivedMessages({'start': most_recent_msg.get('time')}, 'forwards');
}
} else {
this.fetchArchivedMessages({'before': ''});
}
},

View File

@ -98,11 +98,6 @@ u.isSameBareJID = function (jid1, jid2) {
Strophe.getBareJidFromJid(jid2).toLowerCase();
};
u.getMostRecentMessage = function (model) {
const messages = model.messages.filter('message');
return messages[messages.length-1];
}
u.isNewMessage = function (message) {
/* Given a stanza, determine whether it's a new
* message, i.e. not a MAM archived one.