summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2019-07-19 17:26:43 -0400
committerDrew DeVault <sir@cmpwn.com>2019-07-19 17:26:43 -0400
commit97bee661b7e92a28c490fa0e005f203b377e782e (patch)
tree8ed93d20652fab0e6d085fa912355da10233072b
parentd8518909cc888b46ee16804498a71667195f2409 (diff)
downloadaerc-97bee661b7e92a28c490fa0e005f203b377e782e.tar.gz
Fix alternatives config
-rw-r--r--widgets/msgviewer.go7
1 files changed, 5 insertions, 2 deletions
diff --git a/widgets/msgviewer.go b/widgets/msgviewer.go
index 3f9b7fe..7d92861 100644
--- a/widgets/msgviewer.go
+++ b/widgets/msgviewer.go
@@ -56,7 +56,6 @@ func NewMessageViewer(acct *AccountView, conf *config.AercConfig,
 	})
 
 	switcher := &PartSwitcher{}
-	switcher.selected = -1
 	err := createSwitcher(switcher, conf, store, msg)
 	if err != nil {
 		return &MessageViewer{
@@ -164,7 +163,9 @@ func enumerateParts(conf *config.AercConfig, store *lib.MessageStore,
 
 func createSwitcher(switcher *PartSwitcher, conf *config.AercConfig,
 	store *lib.MessageStore, msg *models.MessageInfo) error {
+
 	var err error
+	switcher.selected = -1
 	switcher.showHeaders = conf.Viewer.ShowHeaders
 	switcher.alwaysShowMime = conf.Viewer.AlwaysShowMime
 
@@ -185,6 +186,7 @@ func createSwitcher(switcher *PartSwitcher, conf *config.AercConfig,
 			return err
 		}
 		selectedPriority := -1
+		fmt.Printf("Selecting best message from %v\n", conf.Viewer.Alternatives)
 		for i, pv := range switcher.parts {
 			pv.OnInvalidate(func(_ ui.Drawable) {
 				switcher.Invalidate()
@@ -192,7 +194,8 @@ func createSwitcher(switcher *PartSwitcher, conf *config.AercConfig,
 			// Switch to user's preferred mimetype
 			if switcher.selected == -1 && pv.part.MIMEType != "multipart" {
 				switcher.selected = i
-			} else if selectedPriority == -1 {
+			}
+			if selectedPriority == -1 {
 				for idx, m := range conf.Viewer.Alternatives {
 					if m != pv.part.MIMEType+"/"+pv.part.MIMESubType {
 						continue