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) {