fix: unblock android onboarding after bootstrap pairing

This commit is contained in:
Ayaan Zaidi 2026-03-30 17:33:29 +05:30
parent fec329ce8d
commit e0281849c0
No known key found for this signature in database
3 changed files with 15 additions and 1 deletions

View File

@ -204,6 +204,10 @@ class MainViewModel(app: Application) : AndroidViewModel(app) {
prefs.setOnboardingCompleted(value)
}
fun hasStoredNodeDeviceToken(): Boolean {
return ensureRuntime().hasStoredNodeDeviceToken()
}
fun setCanvasDebugStatusEnabled(value: Boolean) {
prefs.setCanvasDebugStatusEnabled(value)
}

View File

@ -535,6 +535,10 @@ class NodeRuntime(
fun setGatewayBootstrapToken(value: String) = prefs.setGatewayBootstrapToken(value)
fun setGatewayPassword(value: String) = prefs.setGatewayPassword(value)
fun setOnboardingCompleted(value: Boolean) = prefs.setOnboardingCompleted(value)
fun hasStoredNodeDeviceToken(): Boolean {
val deviceId = identityStore.loadOrCreate().deviceId
return !deviceAuthStore.loadToken(deviceId, "node").isNullOrBlank()
}
val lastDiscoveredStableId: StateFlow<String> = prefs.lastDiscoveredStableId
val canvasDebugStatusEnabled: StateFlow<Boolean> = prefs.canvasDebugStatusEnabled
val notificationForwardingEnabled: StateFlow<Boolean> = prefs.notificationForwardingEnabled

View File

@ -228,7 +228,13 @@ fun OnboardingFlow(viewModel: MainViewModel, modifier: Modifier = Modifier) {
var manualTls by rememberSaveable { mutableStateOf(false) }
var gatewayError by rememberSaveable { mutableStateOf<String?>(null) }
var attemptedConnect by rememberSaveable { mutableStateOf(false) }
val canFinishOnboarding = isConnected || (gatewayInputMode == GatewayInputMode.SetupCode && isNodeConnected)
val canRecoverBootstrapRetry =
gatewayInputMode == GatewayInputMode.SetupCode &&
attemptedConnect &&
statusText.contains("bootstrap token invalid or expired", ignoreCase = true) &&
viewModel.hasStoredNodeDeviceToken()
val canFinishOnboarding =
isConnected || (gatewayInputMode == GatewayInputMode.SetupCode && (isNodeConnected || canRecoverBootstrapRetry))
val lifecycleOwner = LocalLifecycleOwner.current
val qrScannerOptions =