aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--commands/msg/utils.go11
-rw-r--r--commands/util.go21
-rw-r--r--lib/marker/marker.go2
3 files changed, 28 insertions, 6 deletions
diff --git a/commands/msg/utils.go b/commands/msg/utils.go
index 4ce82a74..8a00a35e 100644
--- a/commands/msg/utils.go
+++ b/commands/msg/utils.go
@@ -2,6 +2,7 @@ package msg
import (
"errors"
+ "time"
"git.sr.ht/~rjarry/aerc/commands"
"git.sr.ht/~rjarry/aerc/lib"
@@ -11,10 +12,16 @@ import (
type helper struct {
msgProvider widgets.ProvidesMessages
+ statusInfo func(string)
}
func newHelper(aerc *widgets.Aerc) *helper {
- return &helper{aerc.SelectedTabContent().(widgets.ProvidesMessages)}
+ return &helper{
+ msgProvider: aerc.SelectedTabContent().(widgets.ProvidesMessages),
+ statusInfo: func(s string) {
+ aerc.PushStatus(s, 10*time.Second)
+ },
+ }
}
func (h *helper) markedOrSelectedUids() ([]uint32, error) {
@@ -46,5 +53,5 @@ func (h *helper) messages() ([]*models.MessageInfo, error) {
if err != nil {
return nil, err
}
- return commands.MsgInfoFromUids(store, uid)
+ return commands.MsgInfoFromUids(store, uid, h.statusInfo)
}
diff --git a/commands/util.go b/commands/util.go
index 1c4a8c9a..b14e9690 100644
--- a/commands/util.go
+++ b/commands/util.go
@@ -16,6 +16,7 @@ import (
"git.sr.ht/~rjarry/aerc/logging"
"git.sr.ht/~rjarry/aerc/models"
"git.sr.ht/~rjarry/aerc/widgets"
+ "git.sr.ht/~rjarry/aerc/worker/types"
"github.com/gdamore/tcell/v2"
"github.com/mitchellh/go-homedir"
)
@@ -185,8 +186,9 @@ func UidsFromMessageInfos(msgs []*models.MessageInfo) []uint32 {
return uids
}
-func MsgInfoFromUids(store *lib.MessageStore, uids []uint32) ([]*models.MessageInfo, error) {
+func MsgInfoFromUids(store *lib.MessageStore, uids []uint32, statusInfo func(string)) ([]*models.MessageInfo, error) {
infos := make([]*models.MessageInfo, len(uids))
+ needHeaders := make([]uint32, 0)
for i, uid := range uids {
var ok bool
infos[i], ok = store.Messages[uid]
@@ -194,9 +196,24 @@ func MsgInfoFromUids(store *lib.MessageStore, uids []uint32) ([]*models.MessageI
return nil, fmt.Errorf("uid not found")
}
if infos[i] == nil {
- return nil, fmt.Errorf("message store not ready yet")
+ needHeaders = append(needHeaders, uid)
}
}
+ if len(needHeaders) > 0 {
+ store.FetchHeaders(needHeaders, func(msg types.WorkerMessage) {
+ var info string
+ switch m := msg.(type) {
+ case *types.Done:
+ info = "All headers fetched. Please repeat command."
+ case *types.Error:
+ info = fmt.Sprintf("Encountered error while fetching headers: %v", m.Error)
+ }
+ if statusInfo != nil {
+ statusInfo(info)
+ }
+ })
+ return nil, fmt.Errorf("Fetching missing message headers. Please wait.")
+ }
return infos, nil
}
diff --git a/lib/marker/marker.go b/lib/marker/marker.go
index 1b89fc80..46400f1a 100644
--- a/lib/marker/marker.go
+++ b/lib/marker/marker.go
@@ -1,7 +1,5 @@
package marker
-// TODO: fix headers for message that are nil
-
// Marker provides the interface for the marking behavior of messages
type Marker interface {
Mark(uint32)