diff options
author | inwit <inwit@sindominio.net> | 2023-10-29 23:45:55 +0100 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2023-11-02 11:59:39 +0100 |
commit | 9ce4af011c93e2816ce04012f6205b54e0ed1d51 (patch) | |
tree | d7bc32021b9e40bafd26f034d5b44ab7300e5e47 /lib/msgstore.go | |
parent | 2bf8fb42980ea981da34e104d8cfd0d1e3da788b (diff) | |
download | aerc-9ce4af011c93e2816ce04012f6205b54e0ed1d51.tar.gz |
fold: allow for multiple folding levels
Extend the :fold/:unfold behaviour to allow for multiple folding levels.
Signed-Off-By: inwit <inwit@sindominio.net>
Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'lib/msgstore.go')
-rw-r--r-- | lib/msgstore.go | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/msgstore.go b/lib/msgstore.go index c68c2ed8..ca5f16d9 100644 --- a/lib/msgstore.go +++ b/lib/msgstore.go @@ -517,14 +517,23 @@ func (store *MessageStore) Unfold(uid uint32) error { return store.doThreadFolding(uid, false) } -func (store *MessageStore) doThreadFolding(uid uint32, hidden bool) error { +func (store *MessageStore) doThreadFolding(uid uint32, hide bool) error { thread, err := store.Thread(uid) if err != nil { return err } + if hide && thread.FirstChild.Hidden > 0 { + return nil + } err = thread.Walk(func(t *types.Thread, _ int, __ error) error { if t.Uid != uid { - t.Hidden = hidden + if hide { + t.Hidden++ //increase fold level + } else if t.Hidden > 1 { + t.Hidden-- + } else { + t.Hidden = 0 + } } return nil }) |