From 4b2def736f5821d08dfcb7eab6bbb5b45f20bd60 Mon Sep 17 00:00:00 2001 From: hippoz Date: Fri, 20 Nov 2020 21:26:41 +0200 Subject: [PATCH] scroll to the bottom of the message list container when a new message is sent --- app/resources/js/app.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/app/resources/js/app.js b/app/resources/js/app.js index 78aed49..15478dc 100755 --- a/app/resources/js/app.js +++ b/app/resources/js/app.js @@ -229,9 +229,17 @@ const app = new Vue({ processMessage: async function(messageObject) { if (!this.messages[messageObject.category._id]) this.$set(this.messages, messageObject.category._id, []); this.messages[messageObject.category._id].push(messageObject); - + + if (messageObject.category._id === this.selection.category._id) { + this.$nextTick(() => { + // TODO: When the user presses back, actually undo this scroll cause its annoying to scroll back up in the category list + const container = this.$el.querySelector('#posts-container'); + container.scrollTop = container.scrollHeight; + }); + } + if (messageObject.author.username !== this.loggedInUser.username && messageObject.category._id !== this.selection.category._id) { - this.okNotification(`${messageObject.author.username}: ${messageObject.content}`); + this.okNotification(`${messageObject.category.title}/${messageObject.author.username}: ${messageObject.content}`); } }, openChatForCategory: async function(categoryId) { @@ -273,6 +281,7 @@ const app = new Vue({ this.selection.category.browsing = true; this.selection.category.isCategory = false; this.selection.category.isChatContext = false; + this.selection.category._id = '__CATEGORY_LIST'; this.selection.posts = []; this.cardButtons = [];