cleanup accountManager.activeAccount usages in MainActivity (#2021)

main
Konrad Pozniak 3 years ago committed by Alibek Omarov
parent c23d62f26e
commit 3fe199305a
  1. 10
      app/src/main/java/com/keylesspalace/tusky/MainActivity.kt

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

Loading…
Cancel
Save