Getting rid of scroll to bottom code & events that are no longer required

This commit is contained in:
Sylvain Berfini 2023-12-13 17:54:38 +01:00
parent 62ea993847
commit eb5f985712
2 changed files with 0 additions and 33 deletions

View file

@ -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

View file

@ -85,10 +85,6 @@ class ConversationViewModel @UiThread constructor() : ViewModel() {
MutableLiveData<Event<String>>()
}
val scrollToBottomEvent: MutableLiveData<Event<Boolean>> by lazy {
MutableLiveData<Event<Boolean>>()
}
val chatRoomFoundEvent = MutableLiveData<Event<Boolean>>()
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