From f6e78f51fd9d14f8fa1a7bbf415a5ccb6d33cca0 Mon Sep 17 00:00:00 2001 From: Logan Allen Date: Thu, 6 Aug 2020 14:12:29 -0700 Subject: [PATCH] chat: fixed brave slam to bottom issue --- .../src/apps/chat/components/lib/chat-window.tsx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/pkg/interface/src/apps/chat/components/lib/chat-window.tsx b/pkg/interface/src/apps/chat/components/lib/chat-window.tsx index dc81298bdf..bbbc239c43 100644 --- a/pkg/interface/src/apps/chat/components/lib/chat-window.tsx +++ b/pkg/interface/src/apps/chat/components/lib/chat-window.tsx @@ -77,7 +77,11 @@ export class ChatWindow extends Component { } }); } - } else if (state.numPages === 1 && this.props.unreadCount < INITIAL_LOAD) { + } else if ( + state.numPages === 1 && + this.props.unreadCount < INITIAL_LOAD && + this.props.unreadCount > 0 + ) { this.dismissUnread(); this.scrollToBottom(); } @@ -139,12 +143,10 @@ export class ChatWindow extends Component { render() { const { props, state } = this; - const sliceLength = ( - state.numPages * PAGE_SIZE < + const sliceLength = Math.min( + state.numPages * PAGE_SIZE, props.messages.length + props.pendingMessages.length - ) ? state.numPages * PAGE_SIZE : - props.messages.length + props.pendingMessages.length; - + ); const messages = props.pendingMessages .concat(props.messages)