store: extract marking behavior and add tests

Separate the marking functions from the message store and extract the
marking behavior into its own class with tests.

Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
This commit is contained in:
Koni Marti 2022-08-08 22:21:41 +02:00 committed by Robin Jarry
parent ee961d3b1d
commit cfc19a7ec2
14 changed files with 373 additions and 177 deletions
commands/msg

View file

@ -43,9 +43,10 @@ func (Delete) Execute(aerc *widgets.Aerc, args []string) error {
return err
}
sel := store.Selected()
marker := store.Marker()
marker.ClearVisualMark()
// caution, can be nil
next := findNextNonDeleted(uids, store)
store.ClearVisualMark()
store.Delete(uids, func(msg types.WorkerMessage) {
switch msg := msg.(type) {
case *types.Done:
@ -80,11 +81,11 @@ func (Delete) Execute(aerc *widgets.Aerc, args []string) error {
}
}
case *types.Error:
store.Remark()
marker.Remark()
store.Select(sel.Uid)
aerc.PushError(msg.Error.Error())
case *types.Unsupported:
store.Remark()
marker.Remark()
store.Select(sel.Uid)
// notmuch doesn't support it, we want the user to know
aerc.PushError(" error, unsupported for this worker")