From da8056dcdbfdc99bbf2356ceac0436c8286a9f29 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 27 Nov 2024 17:11:30 +0100 Subject: [PATCH 1/2] Fix navigation issue when entering recovery key after navigating from the banner. --- .../io/element/android/appnav/LoggedInFlowNode.kt | 5 +++++ .../securebackup/impl/SecureBackupFlowNode.kt | 13 +++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/appnav/src/main/kotlin/io/element/android/appnav/LoggedInFlowNode.kt b/appnav/src/main/kotlin/io/element/android/appnav/LoggedInFlowNode.kt index 5677d3834d..fa161554cd 100644 --- a/appnav/src/main/kotlin/io/element/android/appnav/LoggedInFlowNode.kt +++ b/appnav/src/main/kotlin/io/element/android/appnav/LoggedInFlowNode.kt @@ -400,6 +400,11 @@ class LoggedInFlowNode @AssistedInject constructor( is NavTarget.SecureBackup -> { secureBackupEntryPoint.nodeBuilder(this, buildContext) .params(SecureBackupEntryPoint.Params(initialElement = navTarget.initialElement)) + .callback(object : SecureBackupEntryPoint.Callback { + override fun onDone() { + backstack.pop() + } + }) .build() } NavTarget.Ftue -> { diff --git a/features/securebackup/impl/src/main/kotlin/io/element/android/features/securebackup/impl/SecureBackupFlowNode.kt b/features/securebackup/impl/src/main/kotlin/io/element/android/features/securebackup/impl/SecureBackupFlowNode.kt index 5d9aeec21e..3fb2d0949a 100644 --- a/features/securebackup/impl/src/main/kotlin/io/element/android/features/securebackup/impl/SecureBackupFlowNode.kt +++ b/features/securebackup/impl/src/main/kotlin/io/element/android/features/securebackup/impl/SecureBackupFlowNode.kt @@ -111,10 +111,15 @@ class SecureBackupFlowNode @AssistedInject constructor( NavTarget.EnterRecoveryKey -> { val callback = object : SecureBackupEnterRecoveryKeyNode.Callback { override fun onEnterRecoveryKeySuccess() { - if (callbacks.isNotEmpty()) { - callbacks.forEach { it.onDone() } - } else { - backstack.pop() + when (plugins.filterIsInstance().first().initialElement) { + SecureBackupEntryPoint.InitialTarget.EnterRecoveryKey -> { + callbacks.forEach { it.onDone() } + } + SecureBackupEntryPoint.InitialTarget.ResetIdentity, + SecureBackupEntryPoint.InitialTarget.Root, + SecureBackupEntryPoint.InitialTarget.SetUpRecovery -> { + backstack.pop() + } } } } From 646b92ac620dfefa36652e6bbfdd845a1f160068 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Fri, 29 Nov 2024 09:07:47 +0100 Subject: [PATCH 2/2] Change to better solution. --- .../securebackup/impl/SecureBackupFlowNode.kt | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/features/securebackup/impl/src/main/kotlin/io/element/android/features/securebackup/impl/SecureBackupFlowNode.kt b/features/securebackup/impl/src/main/kotlin/io/element/android/features/securebackup/impl/SecureBackupFlowNode.kt index 3fb2d0949a..241f132252 100644 --- a/features/securebackup/impl/src/main/kotlin/io/element/android/features/securebackup/impl/SecureBackupFlowNode.kt +++ b/features/securebackup/impl/src/main/kotlin/io/element/android/features/securebackup/impl/SecureBackupFlowNode.kt @@ -28,6 +28,7 @@ import io.element.android.features.securebackup.impl.root.SecureBackupRootNode import io.element.android.features.securebackup.impl.setup.SecureBackupSetupNode import io.element.android.libraries.architecture.BackstackView import io.element.android.libraries.architecture.BaseFlowNode +import io.element.android.libraries.architecture.appyx.canPop import io.element.android.libraries.architecture.createNode import io.element.android.libraries.di.SessionScope import kotlinx.parcelize.Parcelize @@ -111,15 +112,10 @@ class SecureBackupFlowNode @AssistedInject constructor( NavTarget.EnterRecoveryKey -> { val callback = object : SecureBackupEnterRecoveryKeyNode.Callback { override fun onEnterRecoveryKeySuccess() { - when (plugins.filterIsInstance().first().initialElement) { - SecureBackupEntryPoint.InitialTarget.EnterRecoveryKey -> { - callbacks.forEach { it.onDone() } - } - SecureBackupEntryPoint.InitialTarget.ResetIdentity, - SecureBackupEntryPoint.InitialTarget.Root, - SecureBackupEntryPoint.InitialTarget.SetUpRecovery -> { - backstack.pop() - } + if (backstack.canPop()) { + backstack.pop() + } else { + callbacks.forEach { it.onDone() } } } }