Fix selected account to return for messageviewer

This ensures that the selectedaccount is returned if currently selected
tab is a messageviewer. This also makes it more extensible for adding
other ways of getting the selected account.
This commit is contained in:
Jeffas 2019-10-01 18:01:49 +01:00 committed by Drew DeVault
parent f15811a737
commit 00b9ca5032

View file

@ -269,11 +269,13 @@ func (aerc *Aerc) Logger() *log.Logger {
} }
func (aerc *Aerc) SelectedAccount() *AccountView { func (aerc *Aerc) SelectedAccount() *AccountView {
acct, ok := aerc.accounts[aerc.tabs.Tabs[aerc.tabs.Selected].Name] switch tab := aerc.SelectedTab().(type) {
if !ok { case *AccountView:
return nil return tab
case *MessageViewer:
return tab.SelectedAccount()
} }
return acct return nil
} }
func (aerc *Aerc) SelectedTab() ui.Drawable { func (aerc *Aerc) SelectedTab() ui.Drawable {