blob: 4ce82a7494ede8ec942a7f7c0f2f837d0a0a0737 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
package msg
import (
"errors"
"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
}
func newHelper(aerc *widgets.Aerc) *helper {
return &helper{aerc.SelectedTabContent().(widgets.ProvidesMessages)}
}
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)
}
|