From ffc852cda347a39d624e4b1f23422e5456aa4113 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Fri, 23 Oct 2026 23:00:57 +0000 Subject: [PATCH] app: ignore duplicate pushes of the top route Navigator.push() accepted any route, so a double tap (e.g. on an app in the Superuser list) or the same flash request confirmed twice pushed the same route twice. Navigation 3 gives equal routes the same content key, so both copies shared one ViewModel and saved state: a second identical flash request just showed the first one's result, and two back presses were needed to leave. Ignore a push of the route that is already on top. Making routes unique instead would let a double tap start two installs at once. Assisted-by: Claude Opus 5.5 --- .../main/java/com/topjohnwu/magisk/ui/navigation/Navigator.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/apk/src/main/java/com/topjohnwu/magisk/ui/navigation/Navigator.kt b/app/apk/src/main/java/com/topjohnwu/magisk/ui/navigation/Navigator.kt index 2e3e40e1a..1380ea3d8 100644 --- a/app/apk/src/main/java/com/topjohnwu/magisk/ui/navigation/Navigator.kt +++ b/app/apk/src/main/java/com/topjohnwu/magisk/ui/navigation/Navigator.kt @@ -12,6 +12,10 @@ class Navigator(val backStack: NavBackStack) { constructor(vararg initialKeys: NavKey) : this(NavBackStack(*initialKeys)) fun push(key: NavKey) { + // Ignore pushing the screen that is already on top (e.g. a double tap, or the same + // request delivered twice). Both copies would get the same content key, so they would + // share one ViewModel and saved state, and need two back presses to leave. + if (backStack.lastOrNull() == key) return backStack.add(key) }