summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--commands/msg/modify-labels.go17
1 files changed, 7 insertions, 10 deletions
diff --git a/commands/msg/modify-labels.go b/commands/msg/modify-labels.go
index f33a9ca..a18fc15 100644
--- a/commands/msg/modify-labels.go
+++ b/commands/msg/modify-labels.go
@@ -29,19 +29,16 @@ func (ModifyLabels) Execute(aerc *widgets.Aerc, args []string) error {
 		return errors.New("Usage: modify-labels <[+-]label> ...")
 	}
 
-	widget := aerc.SelectedTab().(widgets.ProvidesMessage)
-	acct := widget.SelectedAccount()
-	if acct == nil {
-		return errors.New("No account selected")
-	}
-	store := widget.Store()
-	if store == nil {
-		return errors.New("Cannot perform action. Messages still loading")
+	h := newHelper(aerc)
+	store, err := h.store()
+	if err != nil {
+		return err
 	}
-	msg, err := widget.SelectedMessage()
+	uids, err := h.uids()
 	if err != nil {
 		return err
 	}
+
 	var add, remove []string
 	for _, l := range changes {
 		switch l[0] {
@@ -54,7 +51,7 @@ func (ModifyLabels) Execute(aerc *widgets.Aerc, args []string) error {
 			add = append(add, l)
 		}
 	}
-	store.ModifyLabels([]uint32{msg.Uid}, add, remove, func(
+	store.ModifyLabels(uids, add, remove, func(
 		msg types.WorkerMessage) {
 
 		switch msg := msg.(type) {