From f400aa513c42999c240c015bcdd7bce4b84536a1 Mon Sep 17 00:00:00 2001 From: Alexander Capehart Date: Wed, 16 Aug 2023 19:20:21 -0600 Subject: [PATCH] ui: mitigate navigation desync bug This thing reared it's ugly head again during 3.2.0 testing. I think I've found a terrible but probably functional workaround for it. Start using it. --- app/src/main/java/org/oxycblt/auxio/MainFragment.kt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/src/main/java/org/oxycblt/auxio/MainFragment.kt b/app/src/main/java/org/oxycblt/auxio/MainFragment.kt index c86037eb1..6747acb65 100644 --- a/app/src/main/java/org/oxycblt/auxio/MainFragment.kt +++ b/app/src/main/java/org/oxycblt/auxio/MainFragment.kt @@ -148,6 +148,14 @@ class MainFragment : } } + // Workaround for a bug where fast navigation ends up desynchronizing the current + // destination in the main navigation graph. + findNavController().apply { + findDestination(R.id.main_fragment)?.let { + currentBackStackEntry?.destination = it + } + } + // --- VIEWMODEL SETUP --- collectImmediately(detailModel.editedPlaylist, detailBackCallback::invalidateEnabled) collectImmediately(homeModel.showOuter.flow, ::handleShowOuter)