From db2df9c365b11bf16fd7cfbb8f6cf344690247d9 Mon Sep 17 00:00:00 2001 From: M Date: Wed, 8 Apr 2026 21:35:43 +1000 Subject: [PATCH] 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. --- .../ui/navigation/drawer/AccountSwitchBottomSheet.kt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/drawer/AccountSwitchBottomSheet.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/drawer/AccountSwitchBottomSheet.kt index 9c2dfa282..c5d769bbf 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/drawer/AccountSwitchBottomSheet.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/drawer/AccountSwitchBottomSheet.kt @@ -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) } }