mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-04-19 16:08:29 +00:00
Getting rid of scroll to bottom code & events that are no longer required
This commit is contained in:
parent
62ea993847
commit
eb5f985712
2 changed files with 0 additions and 33 deletions
|
|
@ -303,12 +303,6 @@ class ConversationFragment : SlidingPaneChildFragment() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
viewModel.scrollToBottomEvent.observe(viewLifecycleOwner) {
|
|
||||||
it.consume {
|
|
||||||
scrollToBottom()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
binding.messageBottomSheet.bottomSheetList.setHasFixedSize(true)
|
binding.messageBottomSheet.bottomSheetList.setHasFixedSize(true)
|
||||||
val bottomSheetLayoutManager = LinearLayoutManager(requireContext())
|
val bottomSheetLayoutManager = LinearLayoutManager(requireContext())
|
||||||
binding.messageBottomSheet.bottomSheetList.layoutManager = bottomSheetLayoutManager
|
binding.messageBottomSheet.bottomSheetList.layoutManager = bottomSheetLayoutManager
|
||||||
|
|
@ -518,9 +512,6 @@ class ConversationFragment : SlidingPaneChildFragment() {
|
||||||
binding.root.setKeyboardInsetListener { keyboardVisible ->
|
binding.root.setKeyboardInsetListener { keyboardVisible ->
|
||||||
if (keyboardVisible) {
|
if (keyboardVisible) {
|
||||||
sendMessageViewModel.isEmojiPickerOpen.value = false
|
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) {
|
if (viewModel.scrollingPosition != SCROLLING_POSITION_NOT_SET) {
|
||||||
binding.eventsList.scrollToPosition(viewModel.scrollingPosition)
|
binding.eventsList.scrollToPosition(viewModel.scrollingPosition)
|
||||||
} else {
|
|
||||||
scrollToBottom()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
@ -577,19 +566,6 @@ class ConversationFragment : SlidingPaneChildFragment() {
|
||||||
currentChatMessageModelForBottomSheet = null
|
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) {
|
private fun scrollToFirstUnreadMessageOrBottom(smooth: Boolean) {
|
||||||
if (adapter.itemCount == 0) return
|
if (adapter.itemCount == 0) return
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -85,10 +85,6 @@ class ConversationViewModel @UiThread constructor() : ViewModel() {
|
||||||
MutableLiveData<Event<String>>()
|
MutableLiveData<Event<String>>()
|
||||||
}
|
}
|
||||||
|
|
||||||
val scrollToBottomEvent: MutableLiveData<Event<Boolean>> by lazy {
|
|
||||||
MutableLiveData<Event<Boolean>>()
|
|
||||||
}
|
|
||||||
|
|
||||||
val chatRoomFoundEvent = MutableLiveData<Event<Boolean>>()
|
val chatRoomFoundEvent = MutableLiveData<Event<Boolean>>()
|
||||||
|
|
||||||
lateinit var chatRoom: ChatRoom
|
lateinit var chatRoom: ChatRoom
|
||||||
|
|
@ -138,7 +134,6 @@ class ConversationViewModel @UiThread constructor() : ViewModel() {
|
||||||
override fun onChatMessageSent(chatRoom: ChatRoom, eventLog: EventLog) {
|
override fun onChatMessageSent(chatRoom: ChatRoom, eventLog: EventLog) {
|
||||||
val message = eventLog.chatMessage
|
val message = eventLog.chatMessage
|
||||||
Log.i("$TAG Message [$message] has been sent")
|
Log.i("$TAG Message [$message] has been sent")
|
||||||
scrollToBottomEvent.postValue(Event(true))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@WorkerThread
|
@WorkerThread
|
||||||
|
|
@ -182,10 +177,6 @@ class ConversationViewModel @UiThread constructor() : ViewModel() {
|
||||||
Log.i(
|
Log.i(
|
||||||
"$TAG A reaction [${reaction.body}] was received from [${reaction.fromAddress.asStringUriOnly()}]"
|
"$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
|
@WorkerThread
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue