From 7252c7c1da395370f8fce614e89730c6652d37b7 Mon Sep 17 00:00:00 2001 From: Liam Fitzgerald Date: Mon, 13 Dec 2021 08:35:53 -0500 Subject: [PATCH] interface: fix unreads not clearing chats Fixes urbit/landscape#761 --- .../src/views/apps/chat/components/ChatWindow.tsx | 9 +++++++++ pkg/interface/src/views/components/VirtualScroller.tsx | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/pkg/interface/src/views/apps/chat/components/ChatWindow.tsx b/pkg/interface/src/views/apps/chat/components/ChatWindow.tsx index 5b10257ef..792967ac0 100644 --- a/pkg/interface/src/views/apps/chat/components/ChatWindow.tsx +++ b/pkg/interface/src/views/apps/chat/components/ChatWindow.tsx @@ -161,6 +161,14 @@ class ChatWindow extends Component< } } + onTopLoaded = () => { + const { graphSize, unreadCount } = this.props; + console.log(graphSize, unreadCount); + if(graphSize >= unreadCount) { + this.props.dismissUnread(); + } + }; + onBottomLoaded = () => { if(this.state.unreadIndex.eq(bigInt.zero)) { this.calculateUnreadIndex(); @@ -274,6 +282,7 @@ class ChatWindow extends Component< origin='bottom' style={virtScrollerStyle} onBottomLoaded={this.onBottomLoaded} + onTopLoaded={this.onTopLoaded} // @ts-ignore paging @liam-fitzgerald on virtualscroller props onScroll={this.onScroll} data={graph} diff --git a/pkg/interface/src/views/components/VirtualScroller.tsx b/pkg/interface/src/views/components/VirtualScroller.tsx index 0201b17cf..cb406f2e7 100644 --- a/pkg/interface/src/views/components/VirtualScroller.tsx +++ b/pkg/interface/src/views/components/VirtualScroller.tsx @@ -90,6 +90,11 @@ export interface VirtualScrollerProps { * Callback to execute when finished loading from start */ onBottomLoaded?: () => void; + /* + * Callback to execute when finished loading from end + */ + onTopLoaded?: () => void; + /* * equality function for the key type */ @@ -413,6 +418,9 @@ export default class VirtualScroller extends Component