fix: account switcher bottom sheet not showing logged-in accounts

DisplayAllAccounts collects from accountsFlow() which is a
MutableStateFlow initialized to null. The accounts are lazily loaded
from encrypted storage only when allSavedAccounts() is called, but
nothing in the account switcher triggers that load.

Add a LaunchedEffect that calls allSavedAccounts() when the flow
is still null, ensuring the account list is populated when the
bottom sheet opens.
This commit is contained in:
M
2026-04-08 21:35:43 +10:00
parent 991a187dde
commit db2df9c365
@@ -120,6 +120,15 @@ private fun DisplayAllAccounts(
accountSessionManager: AccountSessionManager,
) {
val accounts by LocalPreferences.accountsFlow().collectAsStateWithLifecycle()
// Trigger lazy load from encrypted storage if the flow hasn't been populated yet.
// accountsFlow() starts as null and only gets a value when allSavedAccounts() is called.
LaunchedEffect(Unit) {
if (accounts == null) {
LocalPreferences.allSavedAccounts()
}
}
accounts?.forEach { acc -> DisplayAccount(acc, accountViewModel, accountSessionManager) }
}