ChatWindow: dismiss unread if we are at bottom of window

This commit is contained in:
Liam Fitzgerald 2021-03-24 13:47:49 +10:00
parent 0f674aab17
commit 1a03b0c63f
No known key found for this signature in database
GPG Key ID: D390E12C61D1CFFB

View File

@ -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() { handleWindowBlur() {
this.setState({ idle: true }); this.setState({ idle: true });
} }
@ -130,6 +135,10 @@ class ChatWindow extends Component<
if(this.prevSize !== graphSize) { if(this.prevSize !== graphSize) {
this.prevSize = graphSize; this.prevSize = graphSize;
if(this.dismissedInitialUnread()
&& this.virtualList?.startOffset() === 0) {
this.dismissUnread();
}
if(this.state.unreadIndex.eq(bigInt.zero)) { if(this.state.unreadIndex.eq(bigInt.zero)) {
this.calculateUnreadIndex(); this.calculateUnreadIndex();
} }