diff options
author | Koni Marti <koni.marti@gmail.com> | 2022-08-08 22:21:45 +0200 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2022-08-22 09:30:37 +0200 |
commit | 117f99e187e16086c1c43a03d640da3294e9e730 (patch) | |
tree | 7cec6d937e31fea03d6244f97eba944ac44e5c40 /worker/types/thread.go | |
parent | b12dd9f9263f7c2cf2f91bc3f6f5549ee0165cb1 (diff) | |
download | aerc-117f99e187e16086c1c43a03d640da3294e9e730.tar.gz |
mark: (un)mark message threads
Mark or unmark the shown message threads. Threads must be available in the
message store. Use the -T option for the mark or unmark commands. Can be
used in combination with the toggle flag (-t).
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'worker/types/thread.go')
-rw-r--r-- | worker/types/thread.go | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/worker/types/thread.go b/worker/types/thread.go index 9f59e9e6..60ecc7ce 100644 --- a/worker/types/thread.go +++ b/worker/types/thread.go @@ -4,6 +4,8 @@ import ( "errors" "fmt" "sort" + + "git.sr.ht/~rjarry/aerc/logging" ) type Thread struct { @@ -48,6 +50,33 @@ func (t *Thread) Walk(walkFn NewThreadWalkFn) error { return err } +// Root returns the root thread of the thread tree +func (t *Thread) Root() *Thread { + if t == nil { + return nil + } + var iter *Thread + for iter = t; iter.Parent != nil; iter = iter.Parent { + } + return iter +} + +// Uids returns all associated uids for the given thread and its children +func (t *Thread) Uids() []uint32 { + if t == nil { + return nil + } + uids := make([]uint32, 0) + err := t.Walk(func(node *Thread, _ int, _ error) error { + uids = append(uids, node.Uid) + return nil + }) + if err != nil { + logging.Errorf("walk to collect uids failed: %w", err) + } + return uids +} + func (t *Thread) String() string { if t == nil { return "<nil>" |