Make AccountManager.getAccountsFlow() only return fully set up accounts

This commit is contained in:
cketti 2022-11-07 16:36:47 +01:00
parent 14693afd94
commit 73d9100087
2 changed files with 7 additions and 5 deletions

View file

@ -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)

View file

@ -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)
}
}
}