scroll to the bottom of the message list container when a new message is sent

This commit is contained in:
hippoz 2020-11-20 21:26:41 +02:00
parent 35d37ea782
commit 4b2def736f

View file

@ -230,8 +230,16 @@ const app = new Vue({
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 = [];