16dbb94221
Fix large archive operations that covers messages in the store with
unfetched headers. Commit e5ad877af5
("msgstore: fetch missing headers
in visual mode") fixed this for the visual selection mode but omitted
the case when 'mark -a' is used to mark all messages.
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
57 lines
1.2 KiB
Go
57 lines
1.2 KiB
Go
package msg
|
|
|
|
import (
|
|
"errors"
|
|
"time"
|
|
|
|
"git.sr.ht/~rjarry/aerc/commands"
|
|
"git.sr.ht/~rjarry/aerc/lib"
|
|
"git.sr.ht/~rjarry/aerc/models"
|
|
"git.sr.ht/~rjarry/aerc/widgets"
|
|
)
|
|
|
|
type helper struct {
|
|
msgProvider widgets.ProvidesMessages
|
|
statusInfo func(string)
|
|
}
|
|
|
|
func newHelper(aerc *widgets.Aerc) *helper {
|
|
return &helper{
|
|
msgProvider: aerc.SelectedTabContent().(widgets.ProvidesMessages),
|
|
statusInfo: func(s string) {
|
|
aerc.PushStatus(s, 10*time.Second)
|
|
},
|
|
}
|
|
}
|
|
|
|
func (h *helper) markedOrSelectedUids() ([]uint32, error) {
|
|
return commands.MarkedOrSelected(h.msgProvider)
|
|
}
|
|
|
|
func (h *helper) store() (*lib.MessageStore, error) {
|
|
store := h.msgProvider.Store()
|
|
if store == nil {
|
|
return nil, errors.New("Cannot perform action. Messages still loading")
|
|
}
|
|
return store, nil
|
|
}
|
|
|
|
func (h *helper) account() (*widgets.AccountView, error) {
|
|
acct := h.msgProvider.SelectedAccount()
|
|
if acct == nil {
|
|
return nil, errors.New("No account selected")
|
|
}
|
|
return acct, nil
|
|
}
|
|
|
|
func (h *helper) messages() ([]*models.MessageInfo, error) {
|
|
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, h.statusInfo)
|
|
}
|