diff --git a/src/plugins/sib-history-improved.js b/src/plugins/sib-history-improved.js index 34eed4f40d7948a6d947921dc5bb8c9bc19fb55e..aaec514a746e73abbde11966950e07d582305eec 100644 --- a/src/plugins/sib-history-improved.js +++ b/src/plugins/sib-history-improved.js @@ -37,6 +37,7 @@ converse.plugins.add('sib-history-improved', { }, initialize() { const { api } = this._converse; + const { log } = converse.env; let counter = 0; // Forces the loading of the real number of messages (or more) @@ -53,10 +54,13 @@ converse.plugins.add('sib-history-improved', { // Stop if there are less messages available than the page size // Stop if the counter registers more messages than the max value if (!max || messages.length < max || counter >= max) { + log.debug(`Chatbox has enough messages or cannot get more, count: ${counter}`); counter = 0; return; } + log.debug(`Chatbox needs more messages, count: ${counter}`); + const is_groupchat = data.chatbox.get('type') === converse.CHATROOMS_TYPE; const oldest_message = messages.pop(); @@ -65,10 +69,12 @@ converse.plugins.add('sib-history-improved', { const stanza_id = oldest_message && oldest_message['stanza_id '.concat(by_jid)]; if (stanza_id) { + log.debug(`Loading messages before stanza: ${stanza_id}`); await data.chatbox.fetchArchivedMessages({ 'before': stanza_id, }); } else { + log.debug(`Loading messages before time: ${oldest_message['time']}`); await data.chatbox.fetchArchivedMessages({ 'end': oldest_message['time'], });