Fixed doubled stack conversations list fragment causing file sharing from outside not working if Linphone opened and already in conversations list

This commit is contained in:
Sylvain Berfini 2024-04-19 09:10:50 +02:00
parent fd7700a819
commit c4358f20f5
5 changed files with 33 additions and 13 deletions

View file

@ -279,9 +279,11 @@ class ConversationFragment : GenericCallFragment() {
}
viewModel.updateEvents.observe(viewLifecycleOwner) {
val items = viewModel.eventsList
adapter.submitList(items)
Log.i("$TAG Events (messages) list updated, contains [${items.size}] items")
it.consume {
val items = viewModel.eventsList
adapter.submitList(items)
Log.i("$TAG Events (messages) list updated, contains [${items.size}] items")
}
}
viewModel.isEndToEndEncrypted.observe(viewLifecycleOwner) { encrypted ->

View file

@ -368,8 +368,15 @@ class MainActivity : GenericActivity() {
}
args?.clear()
val action = ConversationsListFragmentDirections.actionGlobalConversationsListFragment()
findNavController().navigate(action)
if (findNavController().currentDestination?.id == R.id.conversationsListFragment) {
Log.w(
"$TAG Current destination is already conversations list, skipping navigation"
)
} else {
val action =
ConversationsListFragmentDirections.actionGlobalConversationsListFragment()
findNavController().navigate(action)
}
} catch (ise: IllegalStateException) {
Log.e("$TAG Can't navigate to Conversations fragment: $ise")
}
@ -481,7 +488,7 @@ class MainActivity : GenericActivity() {
val pair = parseShortcutIfAny(intent)
if (pair != null) {
Log.i(
"$TAG Navigating to conversation with local [${pair.first}] and peer [${pair.second}] addresses, computed from shortcut ID"
"$TAG Navigating from debug to conversation with local [${pair.first}] and peer [${pair.second}] addresses, computed from shortcut ID"
)
sharedViewModel.showConversationEvent.value = Event(pair)
}
@ -497,8 +504,13 @@ class MainActivity : GenericActivity() {
}
}
val action = ConversationsListFragmentDirections.actionGlobalConversationsListFragment()
findNavController().navigate(action)
if (findNavController().currentDestination?.id == R.id.conversationsListFragment) {
Log.w("$TAG Current destination is already conversations list, skipping navigation")
} else {
val action =
ConversationsListFragmentDirections.actionGlobalConversationsListFragment()
findNavController().navigate(action)
}
}
}

View file

@ -430,12 +430,14 @@ class ConversationFragment : SlidingPaneChildFragment() {
}
viewModel.updateEvents.observe(viewLifecycleOwner) {
val items = viewModel.eventsList
adapter.submitList(items)
Log.i("$TAG Events (messages) list updated, contains [${items.size}] items")
it.consume {
val items = viewModel.eventsList
Log.i("$TAG Events (messages) list submitted, contains [${items.size}] items")
adapter.submitList(items)
(view.parent as? ViewGroup)?.doOnPreDraw {
sharedViewModel.openSlidingPaneEvent.value = Event(true)
(view.parent as? ViewGroup)?.doOnPreDraw {
sharedViewModel.openSlidingPaneEvent.value = Event(true)
}
}
}

View file

@ -315,6 +315,7 @@ class ConversationViewModel @UiThread constructor() : AbstractConversationViewMo
override fun beforeNotifyingChatRoomFound(sameOne: Boolean) {
if (!sameOne) {
Log.i("$TAG Conversation found and not the same as before, configuring it...")
chatRoom.addListener(chatRoomListener)
configureChatRoom()
}

View file

@ -333,6 +333,9 @@ class SendMessageInConversationViewModel @UiThread constructor() : ViewModel() {
if (list.isNotEmpty()) {
isFileAttachmentsListOpen.value = true
Log.i("$TAG [${list.size}] attachment(s) added")
} else {
Log.w("$TAG No attachment to display!")
}
}