aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulio B <julio.bacel@gmail.com>2024-03-06 01:11:04 +0200
committerRobin Jarry <robin@jarry.cc>2024-04-13 21:46:27 +0200
commit672b4edca7af2303cfcb1d69a676556d12476b5f (patch)
tree1f6a574ebf8d44dcbe89c8061dc2be1c06b3b6bf
parent65332c233880c9609ea39af22ee677e98f4cba1b (diff)
downloadaerc-672b4edca7af2303cfcb1d69a676556d12476b5f.tar.gz
aerc-672b4edca7af2303cfcb1d69a676556d12476b5f.zip
notmuch: draw incomplete threads
Create a "pseudo thread" with the first message as root. This is a temporary solution, until we have a more generic implementation of dummy messages that works for all backends. Signed-off-by: Julio B <julio.bacel@gmail.com> Tested-by: Inwit <inwit@sindominio.net> Acked-by: Robin Jarry <robin@jarry.cc>
-rw-r--r--worker/notmuch/lib/database.go16
1 files changed, 11 insertions, 5 deletions
diff --git a/worker/notmuch/lib/database.go b/worker/notmuch/lib/database.go
index 9e66b2ae..bd0bc639 100644
--- a/worker/notmuch/lib/database.go
+++ b/worker/notmuch/lib/database.go
@@ -137,11 +137,17 @@ func (db *DB) ThreadsFromQuery(ctx context.Context, q string, entireThread bool)
thread := threads.Thread()
tlm := thread.TopLevelMessages()
root := db.makeThread(nil, &tlm, entireThread)
- // if len(root) > 1 {
- // TODO make a dummy root node and link all the
- // first level children to it
- // }
- res = append(res, root...)
+ if len(root) > 1 {
+ root[0].FirstChild = root[0].NextSibling
+ root[0].NextSibling.PrevSibling = nil
+ root[0].NextSibling = nil
+ for i := 1; i < len(root); i++ {
+ root[i].Parent = root[0]
+ }
+ res = append(res, root[0])
+ } else {
+ res = append(res, root...)
+ }
tlm.Close()
thread.Close()
}