Skip to content

Commit

Permalink
runfix: revert not sticking to bottom of messages list when navigatin…
Browse files Browse the repository at this point in the history
…g messages

This reverts commit 3e5c864.
  • Loading branch information
atomrc committed Feb 15, 2024
1 parent 4008d22 commit 2c31695
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/script/components/MessagesList/MessageList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,9 @@ export const MessagesList: FC<MessagesListParams> = ({
scrollingContainer.scrollTop = scrollingContainer.scrollHeight - previousScrollHeight;
} else if (shouldStickToBottom) {
// We only want to animate the scroll if there are new messages in the list
const nbNewMessages = filteredMessagesLength - nbMessages.current;
if (nbNewMessages <= 1) {
// We only want to animate the scroll if there is a single new message (many messages added at once means we are navigating the messages list)
const behavior = nbMessages.current !== filteredMessagesLength ? 'smooth' : 'auto';
// Simple content update, we just scroll to bottom if we are in the stick to bottom threshold
scrollingContainer.scrollTo?.({behavior, top: scrollingContainer.scrollHeight});
}
const behavior = nbMessages.current !== filteredMessagesLength ? 'smooth' : 'auto';
// Simple content update, we just scroll to bottom if we are in the stick to bottom threshold
scrollingContainer.scrollTo?.({behavior, top: scrollingContainer.scrollHeight});
} else if (lastMessage && lastMessage.status() === StatusType.SENDING && lastMessage.user().id === selfUser.id) {
// The self user just sent a message, we scroll straight to the bottom
scrollingContainer.scrollTo?.({behavior: 'smooth', top: scrollingContainer.scrollHeight});
Expand Down

0 comments on commit 2c31695

Please sign in to comment.