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>
This commit is contained in:
Koni Marti 2022-10-19 21:38:28 +02:00 committed by Robin Jarry
parent bd8a4feecc
commit c6463ba481

View file

@ -5,7 +5,9 @@ import (
"git.sr.ht/~rjarry/aerc/commands/account" "git.sr.ht/~rjarry/aerc/commands/account"
"git.sr.ht/~rjarry/aerc/lib" "git.sr.ht/~rjarry/aerc/lib"
"git.sr.ht/~rjarry/aerc/models"
"git.sr.ht/~rjarry/aerc/widgets" "git.sr.ht/~rjarry/aerc/widgets"
"git.sr.ht/~rjarry/aerc/worker/types"
) )
type NextPrevMsg struct{} type NextPrevMsg struct{}
@ -37,20 +39,30 @@ func (NextPrevMsg) Execute(aerc *widgets.Aerc, args []string) error {
if err != nil { if err != nil {
return err return err
} }
nextMsg := store.Selected() executeNextPrev := func(nextMsg *models.MessageInfo) {
if nextMsg == nil { lib.NewMessageStoreView(nextMsg, mv.MessageView().SeenFlagSet(),
aerc.RemoveTab(mv) store, aerc.Crypto, aerc.DecryptKeys,
return nil 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(), if nextMsg := store.Selected(); nextMsg != nil {
store, aerc.Crypto, aerc.DecryptKeys, executeNextPrev(nextMsg)
func(view lib.MessageView, err error) { } else {
if err != nil { store.FetchHeaders([]uint32{store.SelectedUid()},
aerc.PushError(err.Error()) func(msg types.WorkerMessage) {
return if m, ok := msg.(*types.MessageInfo); ok {
} executeNextPrev(m.Info)
nextMv := widgets.NewMessageViewer(acct, aerc.Config(), view) }
aerc.ReplaceTab(mv, nextMv, nextMsg.Envelope.Subject) })
}) }
return nil return nil
} }