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 | |
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')
-rw-r--r-- | lib/msgstore.go | 13 | ||||
-rw-r--r-- | lib/threadbuilder.go | 2 |
2 files changed, 12 insertions, 3 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 }) diff --git a/lib/threadbuilder.go b/lib/threadbuilder.go index 1f2d72c6..63ae80d3 100644 --- a/lib/threadbuilder.go +++ b/lib/threadbuilder.go @@ -205,7 +205,7 @@ func (builder *ThreadBuilder) RebuildUids(threads []*types.Thread, inverse bool) t.Deleted = stored.Deleted } builder.threadMap[t.Uid] = t - if t.Deleted || t.Hidden { + if t.Deleted || t.Hidden != 0 { return nil } threaduids = append(threaduids, t.Uid) |