Scroll to bottom of chat after sending a message

Change-Id: I54f71bfe5e5b9f0bbeeafa1b0faa3e9992da442c
This commit is contained in:
SpiritCroc 2021-09-23 18:18:18 +02:00
parent 586f565c23
commit eadc990675
1 changed files with 14 additions and 8 deletions

View File

@ -791,15 +791,8 @@ class RoomDetailFragment @Inject constructor(
private fun setupJumpToBottomView() {
views.jumpToBottomView.visibility = View.INVISIBLE
views.jumpToBottomView.debouncedClicks {
roomDetailViewModel.handle(RoomDetailAction.ExitTrackingUnreadMessagesState)
views.jumpToBottomView.visibility = View.INVISIBLE
if (!roomDetailViewModel.timeline.isLive) {
scrollOnNewMessageCallback.forceScrollOnNextUpdate()
roomDetailViewModel.timeline.restartWithEventId(null)
} else {
roomDetailViewModel.timeline.setInitialEventId(null)
layoutManager.scrollToPositionWithOffset(0, 0)
}
doJumpToBottom()
}
jumpToBottomViewVisibilityManager = JumpToBottomViewVisibilityManager(
@ -810,6 +803,17 @@ class RoomDetailFragment @Inject constructor(
)
}
private fun doJumpToBottom() {
roomDetailViewModel.handle(RoomDetailAction.ExitTrackingUnreadMessagesState)
if (!roomDetailViewModel.timeline.isLive) {
scrollOnNewMessageCallback.forceScrollOnNextUpdate()
roomDetailViewModel.timeline.restartWithEventId(null)
} else {
roomDetailViewModel.timeline.setInitialEventId(null)
layoutManager.scrollToPositionWithOffset(0, 0)
}
}
private fun setupJumpToReadMarkerView() {
views.jumpToReadMarkerView.setOnClickListener {
onJumpToReadMarkerClicked()
@ -1349,6 +1353,8 @@ class RoomDetailFragment @Inject constructor(
lockSendButton = true
roomDetailViewModel.handle(RoomDetailAction.SendMessage(text, vectorPreferences.isMarkdownEnabled()))
emojiPopup.dismiss()
doJumpToBottom()
}
}