From 1a03b0c63f074b0bad5ef5668fda6c550e5b8d4f Mon Sep 17 00:00:00 2001 From: Liam Fitzgerald Date: Wed, 24 Mar 2021 13:47:49 +1000 Subject: [PATCH] ChatWindow: dismiss unread if we are at bottom of window --- .../src/views/apps/chat/components/ChatWindow.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkg/interface/src/views/apps/chat/components/ChatWindow.tsx b/pkg/interface/src/views/apps/chat/components/ChatWindow.tsx index f2ef940b15..7cd778d098 100644 --- a/pkg/interface/src/views/apps/chat/components/ChatWindow.tsx +++ b/pkg/interface/src/views/apps/chat/components/ChatWindow.tsx @@ -114,6 +114,11 @@ class ChatWindow extends Component< }); } + dismissedInitialUnread() { + const { unreadCount, graph } = this.props; + return this.state.unreadIndex.neq(graph.keys()?.[unreadCount]?.[0] ?? bigInt.zero) + } + handleWindowBlur() { this.setState({ idle: true }); } @@ -130,6 +135,10 @@ class ChatWindow extends Component< if(this.prevSize !== graphSize) { this.prevSize = graphSize; + if(this.dismissedInitialUnread() + && this.virtualList?.startOffset() === 0) { + this.dismissUnread(); + } if(this.state.unreadIndex.eq(bigInt.zero)) { this.calculateUnreadIndex(); }