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

Commit 92577708 authored by Mohammed Althaf T's avatar Mohammed Althaf T 😊
Browse files

AM: Handle account changes

parent ce2f5463
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -235,7 +235,7 @@ class AccountSettingsModel @AssistedInject constructor(

    fun updateCredentials(credentials: Credentials) = CoroutineScope(defaultDispatcher).launch {
        accountSettings.credentials(credentials)
        AccountHelper.notifyMailAccountAdded(context)
        AccountHelper.notifyEApps(context, account.name)
        reload()
    }

+3 −3
Original line number Diff line number Diff line
@@ -46,10 +46,10 @@ class AccountReceiver : BroadcastReceiver() {

    private fun handleAccountChange(context: Context) {
        val accountManager = AccountManager.get(context)
        val murenaAccounts = AccountHelper.getAllAccounts(accountManager)
            .filter { it.type == AccountTypes.Murena.accountType }
        val murenaAccount = AccountHelper.getAllAccounts(accountManager)
            .firstOrNull { it.type == AccountTypes.Murena.accountType }

        murenaAccounts.forEach { account ->
        murenaAccount?.let { account ->
            logger.log(Level.INFO, "Account change detected for ${account.name}")
            val authState = accountManager.getUserData(account, AccountSettings.KEY_AUTH_STATE)
            AuthStatePrefUtils.saveAuthState(context, account, authState)