From 5f5eee3be2d927392278fbfb03690b9305a1dbc8 Mon Sep 17 00:00:00 2001 From: Krunal Patel Date: Mon, 21 Nov 2022 10:23:05 +0530 Subject: [PATCH] Fix multiple backstack entries get removed on some fragments --- .../github/libretube/ui/activities/MainActivity.kt | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/github/libretube/ui/activities/MainActivity.kt b/app/src/main/java/com/github/libretube/ui/activities/MainActivity.kt index 591c9d6dd..08a00e62a 100644 --- a/app/src/main/java/com/github/libretube/ui/activities/MainActivity.kt +++ b/app/src/main/java/com/github/libretube/ui/activities/MainActivity.kt @@ -143,12 +143,17 @@ class MainActivity : BaseActivity() { } } - if (navController.currentDestination?.id == startFragmentId) { - moveTaskToBack(true) - } else { - navController.popBackStack(R.id.searchResultFragment, false) || + when (navController.currentDestination?.id) { + startFragmentId -> { + moveTaskToBack(true) + } + R.id.searchResultFragment -> { navController.popBackStack(R.id.searchFragment, true) || + navController.popBackStack() + } + else -> { navController.popBackStack() + } } } })