From 0d22f5c33c965e45593fcb4a276c4ec54ba7132e Mon Sep 17 00:00:00 2001 From: JC Brand Date: Wed, 14 Jun 2017 18:59:39 +0200 Subject: [PATCH] Bugfix. Make sure to only append after a single message. --- src/converse-chatview.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/converse-chatview.js b/src/converse-chatview.js index 9c254ffba..98a398818 100644 --- a/src/converse-chatview.js +++ b/src/converse-chatview.js @@ -253,7 +253,7 @@ * (Object) attrs: An object containing the message * attributes. */ - var msg_dates, idx, + var msg_dates, $first_msg = this.$content.find('.chat-message:first'), first_msg_date = $first_msg.data('isodate'), current_msg_date = moment(attrs.time) || moment, @@ -297,13 +297,12 @@ }); msg_dates.push(current_msg_date); msg_dates.sort(); - idx = msg_dates.indexOf(current_msg_date)-1; + var idx = msg_dates.indexOf(current_msg_date)-1; + var $latest_message = this.$content.find('.chat-message[data-isodate="'+msg_dates[idx]+'"]:last'); _.flow( function ($el) { - $el.insertAfter( - this.$content.find('.chat-message[data-isodate="'+msg_dates[idx]+'"]')); - return $el; - }.bind(this), + $el.insertAfter($latest_message); + }, this.scrollDown.bind(this) )(this.renderMessage(attrs)); },