From e2be2dd4c0a9e2e5b00682a7e4236dfcd4a01fc4 Mon Sep 17 00:00:00 2001 From: Tim Culverhouse Date: Wed, 29 Jun 2022 13:34:54 -0500 Subject: notmuch: fix server-side threads Notmuch server-side threading added messages within a thread that didn't match the query into the uidstore. By doing so, several UI issues presented: * All "hidden" messages displayed at the bottom of the msglist * Selected messages wouldn't open properly This patch stops these messages from being put into the message store, thereby resolving the UI issues Signed-off-by: Tim Culverhouse Acked-by: Koni Marti --- worker/notmuch/lib/database.go | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/worker/notmuch/lib/database.go b/worker/notmuch/lib/database.go index 46a39bc5..670130f4 100644 --- a/worker/notmuch/lib/database.go +++ b/worker/notmuch/lib/database.go @@ -301,6 +301,20 @@ func (db *DB) makeThread(parent *types.Thread, msgs *notmuch.Messages, for msgs.Next(&msg) { msgID := msg.ID() _, inQuery := valid[msgID] + var noReplies bool + replies, err := msg.Replies() + // Replies() returns an error if there are no replies + if err != nil { + noReplies = true + } + if !inQuery { + if noReplies { + continue + } + defer replies.Close() + parent = db.makeThread(parent, replies, valid) + continue + } node := &types.Thread{ Uid: db.uidStore.GetOrInsert(msgID), Parent: parent, @@ -318,9 +332,7 @@ func (db *DB) makeThread(parent *types.Thread, msgs *notmuch.Messages, lastSibling.NextSibling = node } lastSibling = node - replies, err := msg.Replies() - if err != nil { - // if there are no replies it will return an error + if noReplies { continue } defer replies.Close() -- cgit