From 3873fb4bea12b63a0866159ddd973d7f586d7a75 Mon Sep 17 00:00:00 2001
From: ubermanu <e.vodor@gmail.com>
Date: Mon, 15 Mar 2021 16:41:21 +0100
Subject: [PATCH] add debug infos

---
 src/plugins/sib-history-improved.js | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/plugins/sib-history-improved.js b/src/plugins/sib-history-improved.js
index 34eed4f..aaec514 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'],
           });
-- 
GitLab