From 02e50ca3a3c09454706d6cbb94d41736026ea6f0 Mon Sep 17 00:00:00 2001 From: JC Brand Date: Sat, 10 Aug 2019 13:46:01 +0200 Subject: [PATCH] converse-mam: Don't fetch MUC MAM messages on `chatReconnected` event By this time the cached messages are not yet fetched, causing the entire MAM archive to be queried. --- src/headless/converse-mam.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/headless/converse-mam.js b/src/headless/converse-mam.js index f8d9f923e..1a6d02fae 100644 --- a/src/headless/converse-mam.js +++ b/src/headless/converse-mam.js @@ -234,9 +234,13 @@ converse.plugins.add('converse-mam', { _converse.api.listen.on('addClientFeatures', () => _converse.api.disco.own.features.add(Strophe.NS.MAM)); _converse.api.listen.on('serviceDiscovered', getMAMPrefsFromFeature); - _converse.api.listen.on('chatReconnected', chat => chat.fetchNewestMessages()); _converse.api.listen.on('enteredNewRoom', chat => chat.fetchNewestMessages()); - + _converse.api.listen.on('chatReconnected', chat => { + // XXX: For MUCs, we listen to enteredNewRoom instead + if (chat.get('type') === _converse.PRIVATE_CHAT_TYPE) { + chat.fetchNewestMessages(); + } + }); _converse.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.