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 <tim@timculverhouse.com>
Acked-by: Koni Marti <koni.marti@gmail.com>
This commit is contained in:
Tim Culverhouse 2022-06-29 13:34:54 -05:00 committed by Robin Jarry
parent c04446327e
commit e2be2dd4c0
1 changed files with 15 additions and 3 deletions

View File

@ -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()