diff options
-rw-r--r-- | worker/notmuch/eventhandlers.go | 15 | ||||
-rw-r--r-- | worker/notmuch/worker.go | 49 |
2 files changed, 23 insertions, 41 deletions
diff --git a/worker/notmuch/eventhandlers.go b/worker/notmuch/eventhandlers.go index 76517953..db490949 100644 --- a/worker/notmuch/eventhandlers.go +++ b/worker/notmuch/eventhandlers.go @@ -9,7 +9,6 @@ import ( "path/filepath" "strconv" - "git.sr.ht/~rjarry/aerc/lib/log" "git.sr.ht/~rjarry/aerc/worker/types" ) @@ -76,17 +75,9 @@ func (w *worker) updateChangedMessages() error { if err != nil { return fmt.Errorf("Couldn't get updates messages: %w", err) } - for _, uid := range uids { - m, err := w.msgFromUid(uid) - if err != nil { - log.Errorf("%s", err) - continue - } - err = w.emitMessageInfo(m, nil) - if err != nil { - log.Errorf("%s", err) - } - } + w.w.PostMessage(&types.DirectoryContents{ + Uids: uids, + }, nil) w.state = newState return nil } diff --git a/worker/notmuch/worker.go b/worker/notmuch/worker.go index a36b44d4..2a11c1df 100644 --- a/worker/notmuch/worker.go +++ b/worker/notmuch/worker.go @@ -432,12 +432,30 @@ func (w *worker) handleFetchMessageHeaders( w.emitMessageInfoError(msg, uid, err) continue } - err = w.emitMessageInfo(m, msg) + info, err := m.MessageInfo() if err != nil { - w.w.Errorf("could not emit message info: %v", err) w.emitMessageInfoError(msg, uid, err) continue } + switch { + case len(w.headersExclude) > 0: + info.RFC822Headers = lib.LimitHeaders(info.RFC822Headers, w.headersExclude, true) + case len(w.headers) > 0: + info.RFC822Headers = lib.LimitHeaders(info.RFC822Headers, w.headers, false) + } + + switch msg { + case nil: + w.w.PostMessage(&types.MessageInfo{ + Info: info, + }, nil) + default: + w.w.PostMessage(&types.MessageInfo{ + Message: types.RespondTo(msg), + Info: info, + }, nil) + } + } w.done(msg) return nil @@ -679,33 +697,6 @@ func (w *worker) emitMessageInfoError(msg types.WorkerMessage, uid uint32, err e }, nil) } -func (w *worker) emitMessageInfo(m *Message, - parent types.WorkerMessage, -) error { - info, err := m.MessageInfo() - if err != nil { - return fmt.Errorf("could not get MessageInfo: %w", err) - } - switch { - case len(w.headersExclude) > 0: - info.RFC822Headers = lib.LimitHeaders(info.RFC822Headers, w.headersExclude, true) - case len(w.headers) > 0: - info.RFC822Headers = lib.LimitHeaders(info.RFC822Headers, w.headers, false) - } - switch parent { - case nil: - w.w.PostMessage(&types.MessageInfo{ - Info: info, - }, nil) - default: - w.w.PostMessage(&types.MessageInfo{ - Message: types.RespondTo(parent), - Info: info, - }, nil) - } - return nil -} - func (w *worker) emitLabelList() { tags := w.db.ListTags() w.w.PostMessage(&types.LabelList{Labels: tags}, nil) |