cleanup accountManager.activeAccount usages in MainActivity (#2021)

This commit is contained in:
Konrad Pozniak 2020-12-13 16:32:04 +01:00 committed by GitHub
parent 7888408941
commit a19411c947
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 7 deletions

View File

@ -139,12 +139,9 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje
}
}
val accountRequested = accountId != -1L
if (accountRequested) {
val account = accountManager.activeAccount
if (account == null || accountId != account.id) {
if (accountRequested && accountId != activeAccount.id) {
accountManager.setActiveAccount(accountId)
}
}
if (canHandleMimeType(intent.type)) {
// Sharing to Tusky from an external app
if (accountRequested) {
@ -155,8 +152,7 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje
showAccountChooserDialog(getString(R.string.action_share_as), true, object : AccountSelectionListener {
override fun onAccountSelected(account: AccountEntity) {
val requestedId = account.id
val activeAccount = accountManager.activeAccount
if (activeAccount != null && requestedId == activeAccount.id) {
if (requestedId == activeAccount.id) {
// The correct account is already active
forwardShare(intent)
} else {