aboutsummaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
authorKoni Marti <koni.marti@gmail.com>2022-10-19 21:38:28 +0200
committerRobin Jarry <robin@jarry.cc>2022-10-19 21:51:16 +0200
commitc6463ba48167aba07b3fd8bb707dbe60707e9426 (patch)
treeadc9ad4b2390385393748f0fd5be0893fd2eb2bb /commands
parentbd8a4feecc539a50bec005bd2b58af045d9a51bc (diff)
downloadaerc-c6463ba48167aba07b3fd8bb707dbe60707e9426.tar.gz
msgview: enable next/prev with unfetched headers
Fix message view behavior for unfetched headers. When scrolling "over" the message list boundary, current behavior is to close the message viewer tab. Now, the headers will be fetched so that we can scroll through the messages uninterrupted. Fixes: https://todo.sr.ht/~rjarry/aerc/90 Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'commands')
-rw-r--r--commands/msgview/next.go40
1 files changed, 26 insertions, 14 deletions
diff --git a/commands/msgview/next.go b/commands/msgview/next.go
index 6341f931..5df7847d 100644
--- a/commands/msgview/next.go
+++ b/commands/msgview/next.go
@@ -5,7 +5,9 @@ import (
"git.sr.ht/~rjarry/aerc/commands/account"
"git.sr.ht/~rjarry/aerc/lib"
+ "git.sr.ht/~rjarry/aerc/models"
"git.sr.ht/~rjarry/aerc/widgets"
+ "git.sr.ht/~rjarry/aerc/worker/types"
)
type NextPrevMsg struct{}
@@ -37,20 +39,30 @@ func (NextPrevMsg) Execute(aerc *widgets.Aerc, args []string) error {
if err != nil {
return err
}
- nextMsg := store.Selected()
- if nextMsg == nil {
- aerc.RemoveTab(mv)
- return nil
+ executeNextPrev := func(nextMsg *models.MessageInfo) {
+ lib.NewMessageStoreView(nextMsg, mv.MessageView().SeenFlagSet(),
+ store, aerc.Crypto, aerc.DecryptKeys,
+ func(view lib.MessageView, err error) {
+ if err != nil {
+ aerc.PushError(err.Error())
+ return
+ }
+ nextMv := widgets.NewMessageViewer(acct,
+ aerc.Config(), view)
+ aerc.ReplaceTab(mv, nextMv,
+ nextMsg.Envelope.Subject)
+ })
}
- lib.NewMessageStoreView(nextMsg, mv.MessageView().SeenFlagSet(),
- store, aerc.Crypto, aerc.DecryptKeys,
- func(view lib.MessageView, err error) {
- if err != nil {
- aerc.PushError(err.Error())
- return
- }
- nextMv := widgets.NewMessageViewer(acct, aerc.Config(), view)
- aerc.ReplaceTab(mv, nextMv, nextMsg.Envelope.Subject)
- })
+ if nextMsg := store.Selected(); nextMsg != nil {
+ executeNextPrev(nextMsg)
+ } else {
+ store.FetchHeaders([]uint32{store.SelectedUid()},
+ func(msg types.WorkerMessage) {
+ if m, ok := msg.(*types.MessageInfo); ok {
+ executeNextPrev(m.Info)
+ }
+ })
+ }
+
return nil
}