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.
This commit is contained in:
JC Brand 2019-08-10 13:46:01 +02:00
parent ea123e9713
commit 02e50ca3a3

View File

@ -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.