aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReto Brunner <reto@labrat.space>2020-02-29 14:40:51 +0100
committerDrew DeVault <sir@cmpwn.com>2020-02-29 13:16:33 -0500
commitfb2df7e1694a99c8c74e931453aa863125e208f2 (patch)
treec3c43dbd4ef6b3b971a1d320bc96e0559c2b73fd
parent841655a98ec9c570c26ab99c808e763fd33e526c (diff)
notmuch: align dirInfo logic to the maildir worker
-rw-r--r--worker/notmuch/worker.go23
1 files changed, 13 insertions, 10 deletions
diff --git a/worker/notmuch/worker.go b/worker/notmuch/worker.go
index dfcfa77..8b2c477 100644
--- a/worker/notmuch/worker.go
+++ b/worker/notmuch/worker.go
@@ -33,6 +33,7 @@ type worker struct {
w *types.Worker
nmEvents chan eventType
query string
+ currentQueryName string
uidStore *uidstore.Store
nameQueryMap map[string]string
db *notmuch.DB
@@ -118,8 +119,6 @@ func (w *worker) handleMessage(msg types.WorkerMessage) error {
return w.handleSearchDirectory(msg)
case *types.ModifyLabels:
return w.handleModifyLabels(msg)
- case *types.DirectoryInfoUpdateRequest:
- return w.handleDirInfoUpdateRequest(msg)
// not implemented, they are generally not used
// in a notmuch based workflow
@@ -217,14 +216,12 @@ func (w *worker) gatherDirectoryInfo(name string, query string) (
return info, nil
}
-func (w *worker) handleDirInfoUpdateRequest(
- msg *types.DirectoryInfoUpdateRequest) error {
- query := w.queryFromName(msg.Name)
- info, err := w.gatherDirectoryInfo(msg.Name, query)
+func (w *worker) emitDirectoryInfo(name string) error {
+ query := w.queryFromName(name)
+ info, err := w.gatherDirectoryInfo(name, query)
if err != nil {
return err
}
- info.Message = types.RespondTo(msg)
w.w.PostMessage(info, nil)
return nil
}
@@ -244,6 +241,7 @@ func (w *worker) handleOpenDirectory(msg *types.OpenDirectory) error {
w.w.Logger.Printf("opening %s", msg.Directory)
// try the friendly name first, if that fails assume it's a query
w.query = w.queryFromName(msg.Directory)
+ w.currentQueryName = msg.Directory
info, err := w.gatherDirectoryInfo(msg.Directory, w.query)
if err != nil {
return err
@@ -343,11 +341,13 @@ func (w *worker) handleFetchMessageBodyPart(
}
// send updated flags to ui
- err = w.emitMessageInfo(m, msg)
- if err != nil {
+ if err = w.emitMessageInfo(m, msg); err != nil {
+ w.w.Logger.Printf(err.Error())
+ }
+ if err = w.emitDirectoryInfo(w.currentQueryName); err != nil {
w.w.Logger.Printf(err.Error())
- w.err(msg, err)
}
+
w.done(msg)
return nil
}
@@ -396,6 +396,9 @@ func (w *worker) handleReadMessages(msg *types.ReadMessages) error {
continue
}
}
+ if err := w.emitDirectoryInfo(w.currentQueryName); err != nil {
+ w.w.Logger.Printf(err.Error())
+ }
w.done(msg)
return nil
}