forked from hippoz/brainlet
scroll to the bottom of the message list container when a new message is sent
This commit is contained in:
parent
35d37ea782
commit
4b2def736f
1 changed files with 11 additions and 2 deletions
|
@ -229,9 +229,17 @@ const app = new Vue({
|
||||||
processMessage: async function(messageObject) {
|
processMessage: async function(messageObject) {
|
||||||
if (!this.messages[messageObject.category._id]) this.$set(this.messages, messageObject.category._id, []);
|
if (!this.messages[messageObject.category._id]) this.$set(this.messages, messageObject.category._id, []);
|
||||||
this.messages[messageObject.category._id].push(messageObject);
|
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) {
|
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) {
|
openChatForCategory: async function(categoryId) {
|
||||||
|
@ -273,6 +281,7 @@ const app = new Vue({
|
||||||
this.selection.category.browsing = true;
|
this.selection.category.browsing = true;
|
||||||
this.selection.category.isCategory = false;
|
this.selection.category.isCategory = false;
|
||||||
this.selection.category.isChatContext = false;
|
this.selection.category.isChatContext = false;
|
||||||
|
this.selection.category._id = '__CATEGORY_LIST';
|
||||||
this.selection.posts = [];
|
this.selection.posts = [];
|
||||||
|
|
||||||
this.cardButtons = [];
|
this.cardButtons = [];
|
||||||
|
|
Loading…
Reference in a new issue