diff options
author | y0ast <joost@joo.st> | 2021-11-12 18:12:02 +0100 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2021-11-13 15:05:59 +0100 |
commit | dc2a2c2dfd6dc327fe40fbf2da922ef6c3d520be (patch) | |
tree | 4987160692aca01e27b068cb256d66d373556a52 /worker/notmuch/worker.go | |
parent | c303b953360994966ff657c4e17670853198ecf7 (diff) | |
download | aerc-dc2a2c2dfd6dc327fe40fbf2da922ef6c3d520be.tar.gz |
messages: allow displaying email threads
Display threads in the message list. For now, only supported by the
notmuch backend and on IMAP when the server supports the THREAD
extension.
Setting threading-enable=true is global and will cause the message list
to be empty with maildir:// accounts.
Co-authored-by: Kevin Kuehler <keur@xcf.berkeley.edu>
Co-authored-by: Reto Brunner <reto@labrat.space>
Signed-off-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'worker/notmuch/worker.go')
-rw-r--r-- | worker/notmuch/worker.go | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/worker/notmuch/worker.go b/worker/notmuch/worker.go index f8f8b11c..dc362af1 100644 --- a/worker/notmuch/worker.go +++ b/worker/notmuch/worker.go @@ -107,6 +107,8 @@ func (w *worker) handleMessage(msg types.WorkerMessage) error { return w.handleOpenDirectory(msg) case *types.FetchDirectoryContents: return w.handleFetchDirectoryContents(msg) + case *types.FetchDirectoryThreaded: + return w.handleFetchDirectoryThreaded(msg) case *types.FetchMessageHeaders: return w.handleFetchMessageHeaders(msg) case *types.FetchMessageBodyPart: @@ -157,7 +159,6 @@ func (w *worker) handleConfigure(msg *types.Configure) error { return fmt.Errorf("could not resolve home directory: %v", err) } pathToDB := filepath.Join(home, u.Path) - w.uidStore = uidstore.NewStore() err = w.loadQueryMap(msg.Config) if err != nil { return fmt.Errorf("could not load query map configuration: %v", err) @@ -267,6 +268,17 @@ func (w *worker) handleFetchDirectoryContents( return nil } +func (w *worker) handleFetchDirectoryThreaded( + msg *types.FetchDirectoryThreaded) error { + // w.currentSortCriteria = msg.SortCriteria + err := w.emitDirectoryThreaded(msg) + if err != nil { + return err + } + w.done(msg) + return nil +} + func (w *worker) handleFetchMessageHeaders( msg *types.FetchMessageHeaders) error { for _, uid := range msg.Uids { @@ -294,7 +306,7 @@ func (w *worker) uidsFromQuery(query string) ([]uint32, error) { } var uids []uint32 for _, id := range msgIDs { - uid := w.uidStore.GetOrInsert(id) + uid := w.db.UidFromKey(id) uids = append(uids, uid) } @@ -302,7 +314,7 @@ func (w *worker) uidsFromQuery(query string) ([]uint32, error) { } func (w *worker) msgFromUid(uid uint32) (*Message, error) { - key, ok := w.uidStore.GetKey(uid) + key, ok := w.db.KeyFromUid(uid) if !ok { return nil, fmt.Errorf("Invalid uid: %v", uid) } @@ -528,6 +540,18 @@ func (w *worker) emitDirectoryContents(parent types.WorkerMessage) error { return nil } +func (w *worker) emitDirectoryThreaded(parent types.WorkerMessage) error { + threads, err := w.db.ThreadsFromQuery(w.query) + if err != nil { + return err + } + w.w.PostMessage(&types.DirectoryThreaded{ + Message: types.RespondTo(parent), + Threads: threads, + }, nil) + return nil +} + func (w *worker) emitMessageInfo(m *Message, parent types.WorkerMessage) error { info, err := m.MessageInfo() |