interface: fix unreads not clearing chats

Fixes urbit/landscape#761
This commit is contained in:
Liam Fitzgerald 2021-12-13 08:35:53 -05:00
parent 740d9b796e
commit 7252c7c1da
2 changed files with 17 additions and 0 deletions

View File

@ -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}

View File

@ -90,6 +90,11 @@ export interface VirtualScrollerProps<K,V> {
* 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<K,V> extends Component<VirtualScrollerProps
if(newer && this.props.onBottomLoaded) {
this.props.onBottomLoaded();
}
if(!newer && this.props.onTopLoaded) {
this.props.onTopLoaded();
}
}
};