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) { getUpdatedMessageAttributes (message, stanza) {
// Overridden in converse-muc and converse-mam // Overridden in converse-muc and converse-mam
return {}; return {};

View File

@ -73,17 +73,16 @@ converse.plugins.add('converse-mam', {
if (this.disable_mam) { if (this.disable_mam) {
return; return;
} }
const most_recent_msg = u.getMostRecentMessage(this); const most_recent_msg = this.getMostRecentMessage();
if (most_recent_msg) {
if (!most_recent_msg) {
this.fetchArchivedMessages({'before': ''});
} else {
const stanza_id = most_recent_msg.get(`stanza_id ${this.get('jid')}`); const stanza_id = most_recent_msg.get(`stanza_id ${this.get('jid')}`);
if (stanza_id) { if (stanza_id) {
this.fetchArchivedMessages({'after': stanza_id}, 'forwards'); this.fetchArchivedMessages({'after': stanza_id}, 'forwards');
} else { } else {
this.fetchArchivedMessages({'start': most_recent_msg.get('time')}, 'forwards'); 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(); Strophe.getBareJidFromJid(jid2).toLowerCase();
}; };
u.getMostRecentMessage = function (model) {
const messages = model.messages.filter('message');
return messages[messages.length-1];
}
u.isNewMessage = function (message) { u.isNewMessage = function (message) {
/* Given a stanza, determine whether it's a new /* Given a stanza, determine whether it's a new
* message, i.e. not a MAM archived one. * message, i.e. not a MAM archived one.