From 6a41f7f67d33808674dbb864133c453ce8c5e036 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Wed, 22 Jan 2025 10:25:09 +0100 Subject: [PATCH] Another attempt at preventing an empty fragment to be visible sometimes when going back from a conversation --- .../chat/fragment/ConversationFragment.kt | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) 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 c6105c347..79796012b 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 @@ -389,21 +389,22 @@ open class ConversationFragment : SlidingPaneChildFragment() { } override fun goBack(): Boolean { - val backStack = findNavController().currentBackStackEntry - if (backStack == null || backStack.destination.id == R.id.emptyFragment || !findNavController().popBackStack()) { - sharedViewModel.closeSlidingPaneEvent.value = Event(true) - sharedViewModel.displayedChatRoom = null - - if (findNavController().currentDestination?.id == R.id.conversationFragment) { - // If not done this fragment won't be paused, which will cause us issues - val action = - ConversationFragmentDirections.actionConversationFragmentToEmptyFragment() - findNavController().navigate(action) - return true - } - return false + if (viewModel.isCallConversation.value == true) { + Log.i("$TAG Conversation is call related, going back to previous fragment") + return findNavController().popBackStack() } - return true + + sharedViewModel.closeSlidingPaneEvent.value = Event(true) + sharedViewModel.displayedChatRoom = null + + if (findNavController().currentDestination?.id == R.id.conversationFragment) { + // If not done this fragment won't be paused, which will cause us issues + val action = + ConversationFragmentDirections.actionConversationFragmentToEmptyFragment() + findNavController().navigate(action) + return true + } + return false } override fun onViewCreated(view: View, savedInstanceState: Bundle?) {