diff --git a/src/plugins/sib-history-improved.js b/src/plugins/sib-history-improved.js index f09ff47686c01f080005f2381c35372c611efa67..80a5c667836aaef681452ff804a16a1458264b76 100644 --- a/src/plugins/sib-history-improved.js +++ b/src/plugins/sib-history-improved.js @@ -34,6 +34,14 @@ converse.plugins.add('sib-history-improved', { } }, }, + ChatBox: { + /** + * Disable this event handler. + * Causes the history to be fetched twice for private chats. + */ + afterMessagesFetched() { + }, + }, }, initialize() { const _converse = this._converse; @@ -63,7 +71,7 @@ converse.plugins.add('sib-history-improved', { log.debug(`Chatbox needs more messages, count: ${counter}`); const is_groupchat = data.chatbox.get('type') === converse.CHATROOMS_TYPE; - const oldest_message = messages.pop(); + const oldest_message = messages[0] || null; if (oldest_message) { const by_jid = is_groupchat ? data.chatbox.get('jid') : _converse.bare_jid;