From 2c441c79225e1f4412eee4300820f57c4ef5f4fc Mon Sep 17 00:00:00 2001 From: Shpuld Shpuldson Date: Tue, 27 Oct 2020 10:03:04 +0200 Subject: fix back button size, fix missing chat notifications being marked as read too eagerly, fix promiseinterval erroring when not getting a promise --- src/components/chat/chat.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/components/chat/chat.js') diff --git a/src/components/chat/chat.js b/src/components/chat/chat.js index 34e723d0..681ba08f 100644 --- a/src/components/chat/chat.js +++ b/src/components/chat/chat.js @@ -11,6 +11,7 @@ import { getScrollPosition, getNewTopPosition, isBottomedOut, scrollableContaine const BOTTOMED_OUT_OFFSET = 10 const JUMP_TO_BOTTOM_BUTTON_VISIBILITY_OFFSET = 150 const SAFE_RESIZE_TIME_OFFSET = 100 +const MARK_AS_READ_DELAY = 1500 const Chat = { components: { @@ -94,7 +95,7 @@ const Chat = { const bottomedOutBeforeUpdate = this.bottomedOut(BOTTOMED_OUT_OFFSET) this.$nextTick(() => { if (bottomedOutBeforeUpdate) { - this.scrollDown({ forceRead: !document.hidden }) + this.scrollDown() } }) }, @@ -200,7 +201,7 @@ const Chat = { this.$nextTick(() => { scrollable.scrollTo({ top: scrollable.scrollHeight, left: 0, behavior }) }) - if (forceRead || this.newMessageCount > 0) { + if (forceRead) { this.readChat() } }, @@ -225,12 +226,17 @@ const Chat = { } else if (this.bottomedOut(JUMP_TO_BOTTOM_BUTTON_VISIBILITY_OFFSET)) { this.jumpToBottomButtonVisible = false if (this.newMessageCount > 0) { - this.readChat() + // Use a delay before marking as read to prevent situation where new messages + // arrive just as you're leaving the view and messages that you didn't actually + // get to see get marked as read. + window.setTimeout(() => { + if (this.$el) this.readChat() + }, MARK_AS_READ_DELAY) } } else { this.jumpToBottomButtonVisible = true } - }, 100), + }, 200), handleScrollUp (positionBeforeLoading) { const positionAfterLoading = getScrollPosition(this.$refs.scrollable) this.$refs.scrollable.scrollTo({ -- cgit v1.2.3-70-g09d2 From 3ead79ddb42967e2e5e7ccc6d832543b066c7c9b Mon Sep 17 00:00:00 2001 From: Shpuld Shpuldson Date: Thu, 29 Oct 2020 12:45:44 +0200 Subject: document thie this. check --- src/components/chat/chat.js | 1 + 1 file changed, 1 insertion(+) (limited to 'src/components/chat/chat.js') diff --git a/src/components/chat/chat.js b/src/components/chat/chat.js index e60fe09d..c0c9ad6c 100644 --- a/src/components/chat/chat.js +++ b/src/components/chat/chat.js @@ -240,6 +240,7 @@ const Chat = { // arrive just as you're leaving the view and messages that you didn't actually // get to see get marked as read. window.setTimeout(() => { + // Don't mark as read if the element doesn't exist, user has left chat view if (this.$el) this.readChat() }, MARK_AS_READ_DELAY) } -- cgit v1.2.3-70-g09d2