From 46902f7557cd474787e19f0b3e053d37b787f14c Mon Sep 17 00:00:00 2001 From: Satoshi Qazi Muhammed Date: Sun, 18 Oct 2026 14:29:52 +0400 Subject: [PATCH] fix(splash): navigate to the first screen once The splash screen asks for the initial destination on every onResume, which runs again when the activity is recreated during startup while the view model survives. The second navigation found the first already on the welcome screen, with no route from there, and crashed the app with 'Unknown case for welcomeFragment'. The view model now starts it once. --- .../nova/splash/presentation/SplashViewModel.kt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/feature-splash/src/main/java/io/novafoundation/nova/splash/presentation/SplashViewModel.kt b/feature-splash/src/main/java/io/novafoundation/nova/splash/presentation/SplashViewModel.kt index 160dcf9d..0046f717 100644 --- a/feature-splash/src/main/java/io/novafoundation/nova/splash/presentation/SplashViewModel.kt +++ b/feature-splash/src/main/java/io/novafoundation/nova/splash/presentation/SplashViewModel.kt @@ -5,6 +5,7 @@ import io.novafoundation.nova.common.base.BaseViewModel import io.novafoundation.nova.common.utils.splash.SplashPassedObserver import io.novafoundation.nova.feature_account_api.domain.interfaces.AccountRepository import io.novafoundation.nova.splash.SplashRouter +import kotlinx.coroutines.Job import kotlinx.coroutines.launch class SplashViewModel( @@ -13,8 +14,16 @@ class SplashViewModel( private val splashPassedObserver: SplashPassedObserver ) : BaseViewModel() { + private var initialDestinationJob: Job? = null + + // Called from the splash screen's onResume, which runs again when the activity is + // recreated (rotation, theme, locale) while this view model survives. Starting a + // second navigation then finds the first one already on the welcome screen, which + // has no route to welcome, and crashes the app. The first call decides. fun openInitialDestination() { - viewModelScope.launch { + if (initialDestinationJob != null) return + + initialDestinationJob = viewModelScope.launch { if (repository.isAccountSelected()) { openPinCode() } else {