Removed useless code (but rotation still brings user to the bottom of messages, don't know why yet)

This commit is contained in:
Sylvain Berfini 2024-08-29 17:19:57 +02:00
parent 3359fbcbd7
commit 49c3e68f84
2 changed files with 1 additions and 19 deletions

View file

@ -80,7 +80,6 @@ import org.linphone.ui.main.chat.model.MessageReactionsModel
import org.linphone.ui.main.chat.view.RichEditText
import org.linphone.ui.main.chat.viewmodel.ChatMessageLongPressViewModel
import org.linphone.ui.main.chat.viewmodel.ConversationViewModel
import org.linphone.ui.main.chat.viewmodel.ConversationViewModel.Companion.SCROLLING_POSITION_NOT_SET
import org.linphone.ui.main.chat.viewmodel.SendMessageInConversationViewModel
import org.linphone.ui.main.fragment.SlidingPaneChildFragment
import org.linphone.ui.main.history.model.ConfirmationDialogModel
@ -706,6 +705,7 @@ open class ConversationFragment : SlidingPaneChildFragment() {
viewModel.itemToScrollTo.observe(viewLifecycleOwner) { position ->
if (position >= 0) {
Log.i("$TAG Scrolling to message/event at position [$position]")
val recyclerView = binding.eventsList
recyclerView.scrollToPosition(position)
}
@ -878,11 +878,6 @@ open class ConversationFragment : SlidingPaneChildFragment() {
val bottomSheetBehavior = BottomSheetBehavior.from(binding.messageBottomSheet.root)
bottomSheetBehavior.addBottomSheetCallback(bottomSheetCallback)
if (viewModel.scrollingPosition != SCROLLING_POSITION_NOT_SET) {
Log.d("$TAG Restoring previous scrolling position: ${viewModel.scrollingPosition}")
binding.eventsList.scrollToPosition(viewModel.scrollingPosition)
}
}
override fun onPause() {
@ -908,14 +903,6 @@ open class ConversationFragment : SlidingPaneChildFragment() {
Log.e("$TAG Failed to unregister data observer to adapter: $e")
}
if (viewModel.isUserScrollingUp.value == true) {
val layoutManager = binding.eventsList.layoutManager as LinearLayoutManager
viewModel.scrollingPosition = layoutManager.findFirstCompletelyVisibleItemPosition()
Log.d("$TAG Storing current scrolling position: ${viewModel.scrollingPosition}")
} else {
viewModel.scrollingPosition = SCROLLING_POSITION_NOT_SET
}
val bottomSheetBehavior = BottomSheetBehavior.from(binding.messageBottomSheet.root)
bottomSheetBehavior.removeBottomSheetCallback(bottomSheetCallback)
bottomSheetBehavior.state = BottomSheetBehavior.STATE_COLLAPSED

View file

@ -60,8 +60,6 @@ class ConversationViewModel @UiThread constructor() : AbstractConversationViewMo
private const val MESSAGES_PER_PAGE = 30
const val MAX_TIME_TO_GROUP_MESSAGES = 60 // 1 minute
const val SCROLLING_POSITION_NOT_SET = -1
const val ITEMS_TO_LOAD_BEFORE_SEARCH_RESULT = 6
}
@ -103,8 +101,6 @@ class ConversationViewModel @UiThread constructor() : AbstractConversationViewMo
val unreadMessagesCount = MutableLiveData<Int>()
var scrollingPosition: Int = SCROLLING_POSITION_NOT_SET
val focusSearchBarEvent: MutableLiveData<Event<Boolean>> by lazy {
MutableLiveData<Event<Boolean>>()
}
@ -588,7 +584,6 @@ class ConversationViewModel @UiThread constructor() : AbstractConversationViewMo
@WorkerThread
private fun configureChatRoom() {
scrollingPosition = SCROLLING_POSITION_NOT_SET
computeComposingLabel()
isEndToEndEncrypted.postValue(