diff --git a/app/src/main/java/org/linphone/ui/main/chat/fragment/ConversationFragment.kt b/app/src/main/java/org/linphone/ui/main/chat/fragment/ConversationFragment.kt index 94839825c..b80f504c0 100644 --- a/app/src/main/java/org/linphone/ui/main/chat/fragment/ConversationFragment.kt +++ b/app/src/main/java/org/linphone/ui/main/chat/fragment/ConversationFragment.kt @@ -303,12 +303,6 @@ class ConversationFragment : SlidingPaneChildFragment() { } } - viewModel.scrollToBottomEvent.observe(viewLifecycleOwner) { - it.consume { - scrollToBottom() - } - } - binding.messageBottomSheet.bottomSheetList.setHasFixedSize(true) val bottomSheetLayoutManager = LinearLayoutManager(requireContext()) binding.messageBottomSheet.bottomSheetList.layoutManager = bottomSheetLayoutManager @@ -518,9 +512,6 @@ class ConversationFragment : SlidingPaneChildFragment() { binding.root.setKeyboardInsetListener { keyboardVisible -> if (keyboardVisible) { sendMessageViewModel.isEmojiPickerOpen.value = false - - // Scroll to bottom when keyboard is opened so latest message is visible - scrollToBottom() } } } @@ -536,8 +527,6 @@ class ConversationFragment : SlidingPaneChildFragment() { if (viewModel.scrollingPosition != SCROLLING_POSITION_NOT_SET) { binding.eventsList.scrollToPosition(viewModel.scrollingPosition) - } else { - scrollToBottom() } try { @@ -577,19 +566,6 @@ class ConversationFragment : SlidingPaneChildFragment() { currentChatMessageModelForBottomSheet = null } - private fun scrollToBottom() { - if (adapter.itemCount == 0) return - - lifecycleScope.launch { - withContext(Dispatchers.IO) { - delay(100) - withContext(Dispatchers.Main) { - binding.eventsList.scrollToPosition(adapter.itemCount - 1) - } - } - } - } - private fun scrollToFirstUnreadMessageOrBottom(smooth: Boolean) { if (adapter.itemCount == 0) return diff --git a/app/src/main/java/org/linphone/ui/main/chat/viewmodel/ConversationViewModel.kt b/app/src/main/java/org/linphone/ui/main/chat/viewmodel/ConversationViewModel.kt index 22c203ec6..08cd51c41 100644 --- a/app/src/main/java/org/linphone/ui/main/chat/viewmodel/ConversationViewModel.kt +++ b/app/src/main/java/org/linphone/ui/main/chat/viewmodel/ConversationViewModel.kt @@ -85,10 +85,6 @@ class ConversationViewModel @UiThread constructor() : ViewModel() { MutableLiveData>() } - val scrollToBottomEvent: MutableLiveData> by lazy { - MutableLiveData>() - } - val chatRoomFoundEvent = MutableLiveData>() lateinit var chatRoom: ChatRoom @@ -138,7 +134,6 @@ class ConversationViewModel @UiThread constructor() : ViewModel() { override fun onChatMessageSent(chatRoom: ChatRoom, eventLog: EventLog) { val message = eventLog.chatMessage Log.i("$TAG Message [$message] has been sent") - scrollToBottomEvent.postValue(Event(true)) } @WorkerThread @@ -182,10 +177,6 @@ class ConversationViewModel @UiThread constructor() : ViewModel() { Log.i( "$TAG A reaction [${reaction.body}] was received from [${reaction.fromAddress.asStringUriOnly()}]" ) - if (message == (events.value.orEmpty().lastOrNull()?.model as? MessageModel)?.chatMessage) { - // Scrolling to bottom to ensure reaction is visible - scrollToBottomEvent.postValue(Event(true)) - } } @WorkerThread