mirror of
https://github.com/kvorschk/Magisk.git
synced 2026-12-04 19:10:47 -05:00
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
This commit is contained in:
@@ -12,6 +12,10 @@ class Navigator(val backStack: NavBackStack<NavKey>) {
|
||||
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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user