aboutsummaryrefslogtreecommitdiffstats
path: root/commands/msg/mark.go
diff options
context:
space:
mode:
authorKoni Marti <koni.marti@gmail.com>2022-08-08 22:21:41 +0200
committerRobin Jarry <robin@jarry.cc>2022-08-22 09:30:37 +0200
commitcfc19a7ec22a1c60f79427ddbabdf437705efbab (patch)
treefbc4d54f9edb082ff87c84f864df17514c8e34da /commands/msg/mark.go
parentee961d3b1d5ef412b3daf0ef0b8c18ac8957b365 (diff)
downloadaerc-cfc19a7ec22a1c60f79427ddbabdf437705efbab.tar.gz
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>
Diffstat (limited to 'commands/msg/mark.go')
-rw-r--r--commands/msg/mark.go15
1 files changed, 8 insertions, 7 deletions
diff --git a/commands/msg/mark.go b/commands/msg/mark.go
index e15a9f6e..13d6c928 100644
--- a/commands/msg/mark.go
+++ b/commands/msg/mark.go
@@ -31,6 +31,7 @@ func (Mark) Execute(aerc *widgets.Aerc, args []string) error {
if err != nil {
return err
}
+ marker := store.Marker()
opts, _, err := getopt.Getopts(args, "atv")
if err != nil {
return err
@@ -57,9 +58,9 @@ func (Mark) Execute(aerc *widgets.Aerc, args []string) error {
var modFunc func(uint32)
if toggle {
- modFunc = store.ToggleMark
+ modFunc = marker.ToggleMark
} else {
- modFunc = store.Mark
+ modFunc = marker.Mark
}
switch {
case all:
@@ -69,7 +70,7 @@ func (Mark) Execute(aerc *widgets.Aerc, args []string) error {
}
return nil
case visual:
- store.ToggleVisualMark()
+ marker.ToggleVisualMark()
return nil
default:
modFunc(selected.Uid)
@@ -85,21 +86,21 @@ func (Mark) Execute(aerc *widgets.Aerc, args []string) error {
case all && toggle:
uids := store.Uids()
for _, uid := range uids {
- store.ToggleMark(uid)
+ marker.ToggleMark(uid)
}
return nil
case all && !toggle:
- store.ClearVisualMark()
+ marker.ClearVisualMark()
return nil
default:
- store.Unmark(selected.Uid)
+ marker.Unmark(selected.Uid)
return nil
}
case "remark":
if all || visual || toggle {
return fmt.Errorf("Usage: :remark")
}
- store.Remark()
+ marker.Remark()
return nil
}
return nil // never reached