aboutsummaryrefslogtreecommitdiffstats
path: root/worker
diff options
context:
space:
mode:
authorJason Cox <me@jasoncarloscox.com>2024-01-04 23:00:38 -0500
committerRobin Jarry <robin@jarry.cc>2024-01-07 11:43:42 +0100
commitef4b7dc5d46b7d40c79131d812a6296d1bb9668c (patch)
tree4b7230a5596eb060d5aaf7644c0e9864db5f2b4d /worker
parente2c1bafafe06b87a8a7e9639ff427949f4adbf61 (diff)
downloadaerc-ef4b7dc5d46b7d40c79131d812a6296d1bb9668c.tar.gz
notmuch: keep track of all siblings in thread
Consider a thread with a root message and three child messages, each of which has a single child message, like so: root child 1 grandchild 1a child 2 grandchild 2a child 3 grandchild 3a With the previous implementation, if child 2 (or child 3) is not shown by the current query, then grandchild 2a (or grandchild 3a) will not be shown either. Ensure that this bug does not occur; that is, ensure that children of non-queried non-first-child messages are shown in threads. A more complex implementation is possible that maintains only a single loop over the messages, but thinking about it made my head hurt. Use a second (at times redundant) loop instead for simplicity's sake. Changelog-fixed: Don't lose child messages of non-queried parents in notmuch threads Signed-off-by: Jason Cox <me@jasoncarloscox.com> Acked-by: Robin Jarry <robin@jarry.cc> Tested-by: Inwit <inwit@sindominio.net>
Diffstat (limited to 'worker')
-rw-r--r--worker/notmuch/lib/database.go8
1 files changed, 3 insertions, 5 deletions
diff --git a/worker/notmuch/lib/database.go b/worker/notmuch/lib/database.go
index b2a22227..f6e49ae1 100644
--- a/worker/notmuch/lib/database.go
+++ b/worker/notmuch/lib/database.go
@@ -311,7 +311,6 @@ func (db *DB) KeyFromUid(uid uint32) (string, bool) {
}
func (db *DB) makeThread(parent *types.Thread, msgs *notmuch.Messages, threadContext bool) []*types.Thread {
- var lastSibling *types.Thread
var siblings []*types.Thread
for msgs.Next() {
msg := msgs.Message()
@@ -345,12 +344,11 @@ func (db *DB) makeThread(parent *types.Thread, msgs *notmuch.Messages, threadCon
if parent != nil && parent.FirstChild == nil {
parent.FirstChild = node
}
- if lastSibling != nil {
- lastSibling.NextSibling = node
- }
- lastSibling = node
siblings = append(siblings, node)
db.makeThread(node, &replies, threadContext)
}
+ for i := 1; i < len(siblings); i++ {
+ siblings[i-1].NextSibling = siblings[i]
+ }
return siblings
}