From 96569e71a3495965495eed293dddc6d02c601277 Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Tue, 10 Jul 2018 12:20:52 +0300 Subject: [PATCH] Some fixes --- client/components/Chat.vue | 2 +- client/js/lounge.js | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/client/components/Chat.vue b/client/components/Chat.vue index 2108abd8..7363ca5a 100644 --- a/client/components/Chat.vue +++ b/client/components/Chat.vue @@ -114,7 +114,7 @@ export default { "channel.messages"() { const el = this.$refs.chat; - if (el.scrollHeight - el.scrollTop - el.offsetHeight > 30) { + if (!el || el.scrollHeight - el.scrollTop - el.offsetHeight > 30) { return; } diff --git a/client/js/lounge.js b/client/js/lounge.js index 1e2a4063..84c0b9e4 100644 --- a/client/js/lounge.js +++ b/client/js/lounge.js @@ -127,7 +127,11 @@ window.vueMounted = () => { let channel; if (vueApp.activeChannel) { - vueApp.activeChannel.channel.firstUnread = vueApp.activeChannel.channel.messages[vueApp.activeChannel.channel.messages.length - 1].id; + const {channel: lastChannel} = vueApp.activeChannel; + + if (lastChannel.messages.length > 0) { + lastChannel.firstUnread = lastChannel.messages[lastChannel.messages.length - 1].id; + } } if (inSidebar) {