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:
@@ -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()
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user