aboutsummaryrefslogtreecommitdiffstats
path: root/lib/msgstore.go
diff options
context:
space:
mode:
authorKoni Marti <koni.marti@gmail.com>2023-07-14 20:37:30 +0200
committerRobin Jarry <robin@jarry.cc>2023-07-16 10:12:52 +0200
commitc2bcc4bde8b8266d63d447bbfa46acc528ad7dfd (patch)
tree58411ebcb31c447a2016c3506b98068f92470e5c /lib/msgstore.go
parent058eb32c46472554117c5e9d022ff98c617eb99f (diff)
downloadaerc-c2bcc4bde8b8266d63d447bbfa46acc528ad7dfd.tar.gz
store: implement thread folding
Implement thread folding on the message store level. 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 'lib/msgstore.go')
-rw-r--r--lib/msgstore.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/msgstore.go b/lib/msgstore.go
index c6ff5eb2..7c6f91c5 100644
--- a/lib/msgstore.go
+++ b/lib/msgstore.go
@@ -478,6 +478,38 @@ func (store *MessageStore) SelectedThread() (*types.Thread, error) {
return store.Thread(store.SelectedUid())
}
+func (store *MessageStore) Fold(uid uint32) error {
+ return store.doThreadFolding(uid, true)
+}
+
+func (store *MessageStore) Unfold(uid uint32) error {
+ return store.doThreadFolding(uid, false)
+}
+
+func (store *MessageStore) doThreadFolding(uid uint32, hidden bool) error {
+ thread, err := store.Thread(uid)
+ if err != nil {
+ return err
+ }
+ err = thread.Walk(func(t *types.Thread, _ int, __ error) error {
+ if t.Uid != uid {
+ t.Hidden = hidden
+ }
+ return nil
+ })
+ if err != nil {
+ return err
+ }
+ if store.builder == nil {
+ return errors.New("No thread builder available")
+ }
+ store.Select(uid)
+ store.threadsMutex.Lock()
+ store.builder.RebuildUids(store.threads, store.ReverseThreadOrder())
+ store.threadsMutex.Unlock()
+ return nil
+}
+
func (store *MessageStore) Delete(uids []uint32,
cb func(msg types.WorkerMessage),
) {