~sircmpwn/aerc

Fix selected account to return for messageviewer v1 PROPOSED

Thanks!

To git.sr.ht:~sircmpwn/aerc
   f15811a..00b9ca5  master -> master
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~sircmpwn/aerc/%3C20191001170148.40696-1-dev%40jeffas.io%3E/mbox | git am -3
Learn more about email & git

[PATCH] Fix selected account to return for messageviewer Export this patch

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.
---

Hopefully fixes https://todo.sr.ht/~sircmpwn/aerc2/255#comment-3921

 widgets/aerc.go | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/widgets/aerc.go b/widgets/aerc.go
index 16fe8b7..af51a0f 100644
--- a/widgets/aerc.go
+++ b/widgets/aerc.go
@@ -269,11 +269,13 @@ func (aerc *Aerc) Logger() *log.Logger {
 }

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

 func (aerc *Aerc) SelectedTab() ui.Drawable {
--
2.23.0
Thanks!

To git.sr.ht:~sircmpwn/aerc
   f15811a..00b9ca5  master -> master
View this thread in the archives