Make AccountManager.getAccountsFlow()
only return fully set up accounts
This commit is contained in:
parent
14693afd94
commit
73d9100087
2 changed files with 7 additions and 5 deletions
|
@ -110,6 +110,9 @@ class Preferences internal constructor(
|
|||
}
|
||||
}
|
||||
|
||||
private val completeAccounts: List<Account>
|
||||
get() = accounts.filter { it.isFinishedSetup }
|
||||
|
||||
override fun getAccount(accountUuid: String): Account? {
|
||||
synchronized(accountLock) {
|
||||
if (accountsMap == null) {
|
||||
|
@ -151,10 +154,10 @@ class Preferences internal constructor(
|
|||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
override fun getAccountsFlow(): Flow<List<Account>> {
|
||||
return callbackFlow {
|
||||
send(accounts)
|
||||
send(completeAccounts)
|
||||
|
||||
val listener = AccountsChangeListener {
|
||||
trySendBlocking(accounts)
|
||||
trySendBlocking(completeAccounts)
|
||||
}
|
||||
addOnAccountsChangeListener(listener)
|
||||
|
||||
|
|
|
@ -77,11 +77,10 @@ class SettingsListFragment : Fragment(), ItemTouchCallback {
|
|||
|
||||
private fun populateSettingsList() {
|
||||
viewModel.accounts.observeNotNull(this) { accounts ->
|
||||
val accountsFinishedSetup = accounts.filter { it.isFinishedSetup }
|
||||
if (accountsFinishedSetup.isEmpty()) {
|
||||
if (accounts.isEmpty()) {
|
||||
launchOnboarding()
|
||||
} else {
|
||||
populateSettingsList(accountsFinishedSetup)
|
||||
populateSettingsList(accounts)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue