session: reuse removeAccount method for log out

The removeAccount method takes care of invoking the non-deprecated
API in applicable API levels. The logout method did not do such a
thing. Avoid redundancy, and reuse the removeAccount method for
logging out.
This commit is contained in:
Kaartic Sivaraam 2024-05-12 23:12:21 +05:30
parent 1f6f186b98
commit 6aefc07a51

View file

@ -125,13 +125,15 @@ public class SessionManager {
* Returns a Completable that clears existing accounts from account manager * Returns a Completable that clears existing accounts from account manager
*/ */
public Completable logout() { public Completable logout() {
AccountManager accountManager = AccountManager.get(context); return Completable.fromObservable(
Account[] allAccounts = accountManager.getAccountsByType(BuildConfig.ACCOUNT_TYPE); Observable.empty()
return Completable.fromObservable(Observable.fromArray(allAccounts) .doOnComplete(
.map(a -> accountManager.removeAccount(a, null, null).getResult())) () -> {
.doOnComplete(() -> { removeAccount();
currentAccount = null; currentAccount = null;
}); }
)
);
} }
/** /**