aboutsummaryrefslogtreecommitdiffstats
path: root/worker
diff options
context:
space:
mode:
Diffstat (limited to 'worker')
-rw-r--r--worker/notmuch/lib/database.go19
-rw-r--r--worker/notmuch/worker.go4
-rw-r--r--worker/types/messages.go1
-rw-r--r--worker/types/thread.go4
4 files changed, 20 insertions, 8 deletions
diff --git a/worker/notmuch/lib/database.go b/worker/notmuch/lib/database.go
index 9a6689c4..e7914156 100644
--- a/worker/notmuch/lib/database.go
+++ b/worker/notmuch/lib/database.go
@@ -111,7 +111,7 @@ func (db *DB) MsgIDsFromQuery(ctx context.Context, q string) ([]string, error) {
return msgIDs, err
}
-func (db *DB) ThreadsFromQuery(ctx context.Context, q string) ([]*types.Thread, error) {
+func (db *DB) ThreadsFromQuery(ctx context.Context, q string, entireThread bool) ([]*types.Thread, error) {
query, err := db.newQuery(q)
if err != nil {
return nil, err
@@ -136,7 +136,7 @@ func (db *DB) ThreadsFromQuery(ctx context.Context, q string) ([]*types.Thread,
default:
thread := threads.Thread()
tlm := thread.TopLevelMessages()
- root := db.makeThread(nil, &tlm)
+ root := db.makeThread(nil, &tlm, entireThread)
res = append(res, root)
tlm.Close()
thread.Close()
@@ -306,7 +306,7 @@ func (db *DB) KeyFromUid(uid uint32) (string, bool) {
return db.uidStore.GetKey(uid)
}
-func (db *DB) makeThread(parent *types.Thread, msgs *notmuch.Messages) *types.Thread {
+func (db *DB) makeThread(parent *types.Thread, msgs *notmuch.Messages, threadContext bool) *types.Thread {
var lastSibling *types.Thread
for msgs.Next() {
msg := msgs.Message()
@@ -319,14 +319,19 @@ func (db *DB) makeThread(parent *types.Thread, msgs *notmuch.Messages) *types.Th
}
replies := msg.Replies()
defer replies.Close()
- if !match {
- parent = db.makeThread(parent, &replies)
+ if !match && !threadContext {
+ parent = db.makeThread(parent, &replies, threadContext)
continue
}
node := &types.Thread{
Uid: db.uidStore.GetOrInsert(msgID),
Parent: parent,
- Hidden: !match,
+ }
+ switch threadContext {
+ case true:
+ node.Context = !match
+ default:
+ node.Hidden = !match
}
if parent != nil && parent.FirstChild == nil {
parent.FirstChild = node
@@ -340,7 +345,7 @@ func (db *DB) makeThread(parent *types.Thread, msgs *notmuch.Messages) *types.Th
lastSibling.NextSibling = node
}
lastSibling = node
- db.makeThread(node, &replies)
+ db.makeThread(node, &replies, threadContext)
}
// We want to return the root node
diff --git a/worker/notmuch/worker.go b/worker/notmuch/worker.go
index d1eb69d0..2f601528 100644
--- a/worker/notmuch/worker.go
+++ b/worker/notmuch/worker.go
@@ -635,6 +635,7 @@ func (w *worker) emitDirectoryContents(parent types.WorkerMessage) error {
func (w *worker) emitDirectoryThreaded(parent types.WorkerMessage) error {
query := w.query
ctx := context.Background()
+ threadContext := false
if msg, ok := parent.(*types.FetchDirectoryThreaded); ok {
log.Debugf("filter input: '%v'", msg.FilterCriteria)
s, err := translate(msg.FilterCriteria)
@@ -646,8 +647,9 @@ func (w *worker) emitDirectoryThreaded(parent types.WorkerMessage) error {
log.Debugf("filter query: '%s'", query)
}
ctx = msg.Context
+ threadContext = msg.ThreadContext
}
- threads, err := w.db.ThreadsFromQuery(ctx, query)
+ threads, err := w.db.ThreadsFromQuery(ctx, query, threadContext)
if err != nil {
return err
}
diff --git a/worker/types/messages.go b/worker/types/messages.go
index 26408684..7cab9a7a 100644
--- a/worker/types/messages.go
+++ b/worker/types/messages.go
@@ -115,6 +115,7 @@ type FetchDirectoryThreaded struct {
Context context.Context
SortCriteria []*SortCriterion
FilterCriteria []string
+ ThreadContext bool
}
type SearchDirectory struct {
diff --git a/worker/types/thread.go b/worker/types/thread.go
index 2f739bc2..75651280 100644
--- a/worker/types/thread.go
+++ b/worker/types/thread.go
@@ -17,6 +17,10 @@ type Thread struct {
Hidden bool // if this flag is set the message isn't rendered in the UI
Deleted bool // if this flag is set the message was deleted
+
+ // Context indicates the message doesn't match the mailbox / query but
+ // is displayed for context
+ Context bool
}
// AddChild appends the child node at the end of the existing children of t.