From 315b8aaacc4da3219b6120449d0f7ef6b93d925e Mon Sep 17 00:00:00 2001 From: Honey Date: Wed, 22 Jul 2026 19:56:10 +0200 Subject: [PATCH] fix(android): re-assert Erkunden overlay back priority on every navigation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The root-level overlay back callback was keyed only on the overlay state, so after an album drill-down or tab switch the NavHost could re-register its own back callback above ours and regain priority — one back press then popped Erkunden → Home instead of dismissing the overlay ("sometimes" bug). Key the DisposableEffect on currentBackEntry as well, so the callback is removed and re-added (bumped to the top of the OnBackPressedDispatcher) after every navigation while an overlay is open. Co-Authored-By: Claude Opus 4.8 --- .../com/novasonic/app/ui/AppNavigation.kt | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/android/app/src/main/kotlin/com/novasonic/app/ui/AppNavigation.kt b/android/app/src/main/kotlin/com/novasonic/app/ui/AppNavigation.kt index a2c693a..929bb89 100644 --- a/android/app/src/main/kotlin/com/novasonic/app/ui/AppNavigation.kt +++ b/android/app/src/main/kotlin/com/novasonic/app/ui/AppNavigation.kt @@ -126,16 +126,6 @@ fun AppNavigation() { backDispatcher.addCallback(cb) onDispose { cb.remove() } } - DisposableEffect(exploreOverlayBack, backDispatcher) { - val action = exploreOverlayBack - if (action == null || backDispatcher == null) return@DisposableEffect onDispose {} - val cb = object : OnBackPressedCallback(true) { - override fun handleOnBackPressed() { action() } - } - backDispatcher.addCallback(cb) - onDispose { cb.remove() } - } - fun coverUrl(coverId: String?) = repo.coverArtUrl(coverId, 600) fun heroCoverUrl(coverId: String?) = repo.coverArtUrl(coverId, 1000) @@ -152,6 +142,20 @@ fun AppNavigation() { val currentRoute = currentBackEntry?.destination?.route val isTopLevel = TopLevel.entries.any { it.route == currentRoute } + // Root-level back for the Erkunden (Apple) overlay. Keyed on currentBackEntry as well, so the + // callback is re-added (bumped to the top of the OnBackPressedDispatcher) after every navigation + // — otherwise, once the NavHost re-registers its own callback during an album drill-down or tab + // switch, it could regain priority and pop Erkunden → Home on the next back ("sometimes" bug). + DisposableEffect(exploreOverlayBack, backDispatcher, currentBackEntry) { + val action = exploreOverlayBack + if (action == null || backDispatcher == null) return@DisposableEffect onDispose {} + val cb = object : OnBackPressedCallback(true) { + override fun handleOnBackPressed() { action() } + } + backDispatcher.addCallback(cb) + onDispose { cb.remove() } + } + val bgGlow = Brush.radialGradient( colors = listOf(Color(0x0AE8A020), Color(0x00000000)), center = Offset.Unspecified, radius = 900f,