fix: trigger loadAccounts() on auth and loadCachedSchedule() on account selection

The schedule screen was never loading data because no LaunchedEffect
called loadAccounts() when the user became authenticated. Now:
- App.kt: calls scheduleViewModel.loadAccounts() when authState becomes Authenticated
- ScheduleScreen.kt: calls loadCachedSchedule() when selectedAccount is set
This commit is contained in:
2026-07-08 18:07:21 +02:00
parent b676c768fe
commit d93cae0816
2 changed files with 10 additions and 0 deletions
@@ -54,6 +54,9 @@ fun App(
is AuthState.Unauthenticated -> Screen.Login
AuthState.Loading -> currentScreen
}
if (authState is AuthState.Authenticated) {
scheduleViewModel.loadAccounts()
}
}
MyIceTheme {
@@ -17,6 +17,7 @@ import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.material3.TopAppBar
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
@@ -44,6 +45,12 @@ fun ScheduleScreen(
val scheduleState by scheduleViewModel.state.collectAsState()
val authState by authViewModel.state.collectAsState()
LaunchedEffect(scheduleState.selectedAccount) {
if (scheduleState.selectedAccount != null && scheduleState.events.isEmpty()) {
scheduleViewModel.loadCachedSchedule()
}
}
Scaffold(
topBar = {
TopAppBar(