MAM: Always query for newest MAM messages after cached ones have been fetched

The `_converse.connection.restored` check ensured that 1:1 chats
manually opened after tab reload would never get their MAM messages
fetched 🤦
This commit is contained in:
JC Brand 2022-08-17 13:53:31 +02:00
parent 51516e38f6
commit e8b9681a15

View File

@ -48,19 +48,13 @@ converse.plugins.add('converse-mam', {
api.listen.on('enteredNewRoom', muc => muc.features.get('mam_enabled') && fetchNewestMessages(muc));
api.listen.on('chatReconnected', chat => {
// XXX: For MUCs, we listen to enteredNewRoom instead
if (chat.get('type') === _converse.PRIVATE_CHAT_TYPE) {
fetchNewestMessages(chat);
}
});
api.listen.on('afterMessagesFetched', chat => {
// XXX: We don't want to query MAM every time this is triggered
// since it's not necessary when the chat is restored from cache.
// (given that BOSH or SMACKS will ensure that you get messages
// sent during the reload).
// With MUCs we can listen for `enteredNewRoom`.
if (chat.get('type') === _converse.PRIVATE_CHAT_TYPE && !_converse.connection.restored) {
if (chat.get('type') === _converse.PRIVATE_CHAT_TYPE) {
fetchNewestMessages(chat);
}
});