aboutsummaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
authorKoni Marti <koni.marti@gmail.com>2023-07-14 20:37:28 +0200
committerRobin Jarry <robin@jarry.cc>2023-07-16 10:12:38 +0200
commit1a067bcb339a338043abfb62e4f946787b734af7 (patch)
tree479d32dcfc3ee8d9d0021896f38d08fdd391a52b /commands
parentb08d38c1e57934fec2f244444c233a1bca58ed76 (diff)
downloadaerc-1a067bcb339a338043abfb62e4f946787b734af7.tar.gz
threadbuilder: store uid/thread association
Store the association between uids and threads in a map instead of just having the threads in a slice. This simplifies the lookup of a thread when we have an uid and we can avoid computationally expensive tree walks. The threadbuilder will rebuild the uids from the given thread structure. Hence there is no need now to keep a threads slice around. Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc> Tested-by: inwit <inwit@sindominio.net>
Diffstat (limited to 'commands')
-rw-r--r--commands/msg/mark.go16
1 files changed, 10 insertions, 6 deletions
diff --git a/commands/msg/mark.go b/commands/msg/mark.go
index dcb6d69d..51aa1eb4 100644
--- a/commands/msg/mark.go
+++ b/commands/msg/mark.go
@@ -64,10 +64,6 @@ func (Mark) Execute(aerc *widgets.Aerc, args []string) error {
}
}
- if thread && len(store.Threads()) == 0 {
- return fmt.Errorf("No threads found")
- }
-
if thread && all {
return fmt.Errorf("-a and -T are mutually exclusive")
}
@@ -100,7 +96,11 @@ func (Mark) Execute(aerc *widgets.Aerc, args []string) error {
return nil
default:
if thread {
- for _, uid := range store.SelectedThread().Root().Uids() {
+ threadPtr, err := store.SelectedThread()
+ if err != nil {
+ return err
+ }
+ for _, uid := range threadPtr.Root().Uids() {
modFunc(uid)
}
} else {
@@ -126,7 +126,11 @@ func (Mark) Execute(aerc *widgets.Aerc, args []string) error {
return nil
default:
if thread {
- for _, uid := range store.SelectedThread().Root().Uids() {
+ threadPtr, err := store.SelectedThread()
+ if err != nil {
+ return err
+ }
+ for _, uid := range threadPtr.Root().Uids() {
marker.Unmark(uid)
}
} else {