Skip to content

Commit

Permalink
Merge pull request #1121 from radixdlt/fix/ABW-3668-pop-persona-creat…
Browse files Browse the repository at this point in the history
…ion-crash

Fix crash when popping persona creation flow.
  • Loading branch information
jakub-rdx authored Aug 6, 2024
2 parents 1a71911 + b652bdf commit 274b761
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import com.babylon.wallet.android.presentation.navigation.markAsHighPriority
import com.babylon.wallet.android.presentation.settings.personas.PersonasScreen
import com.babylon.wallet.android.presentation.settings.personas.personadetail.ROUTE_PERSONA_DETAIL
import com.radixdlt.sargon.IdentityAddress
import rdx.works.core.flatMapError

const val ROUTE_CREATE_PERSONA = "create_persona_route"
const val ROUTE_PERSONA_INFO = "persona_info_route"
Expand All @@ -29,14 +30,15 @@ fun NavController.personaInfoScreen() {
navigate(ROUTE_PERSONA_INFO)
}

@Suppress("SwallowedException")
fun NavController.popPersonaCreation() {
val entryToPop = try {
getBackStackEntry(ROUTE_PERSONA_INFO)
} catch (e: java.lang.IllegalArgumentException) {
getBackStackEntry(ROUTE_CREATE_PERSONA)
val entryToPop = runCatching { getBackStackEntry(ROUTE_PERSONA_INFO) }.flatMapError {
runCatching { getBackStackEntry(ROUTE_CREATE_PERSONA) }
}.getOrNull()
if (entryToPop == null) {
popBackStack()
} else {
popBackStack(entryToPop.destination.id, true)
}
popBackStack(entryToPop.destination.id, true)
}

fun NavGraphBuilder.personaInfoScreen(
Expand Down

0 comments on commit 274b761

Please sign in to comment.