Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit b0636a32 authored by cketti's avatar cketti Committed by GitHub
Browse files

Merge pull request #6464 from thundernest/fix_cancel_account_creation_bug

Fix bug when account setup is canceled
parents 14693afd 04d97b4e
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -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)

+9 −1
Original line number Diff line number Diff line
@@ -36,7 +36,7 @@ class AccountRemover(

        preferences.deleteAccount(account)

        localKeyStoreManager.deleteCertificates(account)
        removeCertificates(account)
        Core.setServicesEnabled()

        Timber.v("Finished removing account '%s'.", accountName)
@@ -62,4 +62,12 @@ class AccountRemover(
            Timber.e(e, "Failed to reset remote store for account %s", account)
        }
    }

    private fun removeCertificates(account: Account) {
        try {
            localKeyStoreManager.deleteCertificates(account)
        } catch (e: Exception) {
            Timber.e(e, "Failed to remove certificates for account %s", account)
        }
    }
}
+2 −3
Original line number Diff line number Diff line
@@ -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)
            }
        }
    }