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:
parent
bd8a4feecc
commit
c6463ba481
1 changed files with 26 additions and 14 deletions
|
@ -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,11 +39,7 @@ 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) {
|
||||
|
@ -49,8 +47,22 @@ func (NextPrevMsg) Execute(aerc *widgets.Aerc, args []string) error {
|
|||
aerc.PushError(err.Error())
|
||||
return
|
||||
}
|
||||
nextMv := widgets.NewMessageViewer(acct, aerc.Config(), view)
|
||||
aerc.ReplaceTab(mv, nextMv, nextMsg.Envelope.Subject)
|
||||
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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue