about summary refs log tree commit diff stats
path: root/commands/msg
diff options
context:
space:
mode:
authorReto Brunner <reto@labrat.space>2020-05-09 11:50:31 +0200
committerDrew DeVault <sir@cmpwn.com>2020-05-11 09:47:34 -0400
commitea2646fc039a572491ba8cc8e2879b7bf61c25dd (patch)
tree3608b8064e4f67f1f53e177ddad2e5f5ae9a49d5 /commands/msg
parent381c1fc05f6de95accbb520769d0cc9196955cf4 (diff)
downloadaerc-ea2646fc039a572491ba8cc8e2879b7bf61c25dd.tar.gz
Change MarkedMessages to return uids
Especially if one tries to interact with all marked messages there could be
the case that not all headers are fetched yet, hence the messageInfo is still nil.

This segfaults a lot of commands which in principle only need the uid to complete.

If we switch to uids, this issue can be alleviated for those commands.
Diffstat (limited to 'commands/msg')
-rw-r--r--commands/msg/utils.go17
1 files changed, 10 insertions, 7 deletions
diff --git a/commands/msg/utils.go b/commands/msg/utils.go
index ae25535..cad0f82 100644
--- a/commands/msg/utils.go
+++ b/commands/msg/utils.go
@@ -18,12 +18,7 @@ func newHelper(aerc *widgets.Aerc) *helper {
 }
 
 func (h *helper) markedOrSelectedUids() ([]uint32, error) {
-	msgs, err := commands.MarkedOrSelected(h.msgProvider)
-	if err != nil {
-		return nil, err
-	}
-	uids := commands.UidsFromMessageInfos(msgs)
-	return uids, nil
+	return commands.MarkedOrSelected(h.msgProvider)
 }
 
 func (h *helper) store() (*lib.MessageStore, error) {
@@ -43,5 +38,13 @@ func (h *helper) account() (*widgets.AccountView, error) {
 }
 
 func (h *helper) messages() ([]*models.MessageInfo, error) {
-	return commands.MarkedOrSelected(h.msgProvider)
+	uid, err := commands.MarkedOrSelected(h.msgProvider)
+	if err != nil {
+		return nil, err
+	}
+	store, err := h.store()
+	if err != nil {
+		return nil, err
+	}
+	return commands.MsgInfoFromUids(store, uid)
 }