Fix login scan not restarting after logout

Move scan trigger from ViewModel init to LaunchedEffect in LoginScreen
so discovery runs each time the screen appears, not just on first creation.
This commit is contained in:
2026-03-04 14:39:29 +01:00
parent b3522bc1c4
commit 76dc176fd3
2 changed files with 5 additions and 4 deletions

View File

@@ -26,6 +26,11 @@ fun LoginScreen(
) {
val uiState by viewModel.uiState.collectAsStateWithLifecycle()
// Start scanning each time the login screen appears
LaunchedEffect(Unit) {
viewModel.startScan()
}
LaunchedEffect(uiState.loginSuccess) {
if (uiState.loginSuccess) onLoginSuccess()
}

View File

@@ -57,10 +57,6 @@ class LoginViewModel @Inject constructor(
private var scanJob: Job? = null
private val lanTls by lazy { LanTlsFactory.create(context) }
init {
startScan()
}
fun startScan() {
scanJob?.cancel()
_uiState.value = LoginUiState(phase = LoginPhase.SCANNING)