~sircmpwn/aerc

imap: emit messageinfo when changing read state. v1 PROPOSED

Reto Brunner: 1
 imap: emit messageinfo when changing read state.

 1 files changed, 17 insertions(+), 2 deletions(-)
... I need more coffee apparently.

Thanks a lot for catching that Ben, v2 incoming
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~sircmpwn/aerc/patches/9588/mbox | git am -3
Learn more about email & git

[PATCH] imap: emit messageinfo when changing read state. Export this patch

We need to emit the changed msgInfo whenever we modify the state
---
Easiest way to do that is to simply emit the fetchHeaders action.
Any objections in doing that?

 worker/imap/flags.go | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/worker/imap/flags.go b/worker/imap/flags.go
index 57211a6..011cf54 100644
--- a/worker/imap/flags.go
+++ b/worker/imap/flags.go
@@ -1,6 +1,7 @@
package imap

import (
	"fmt"
	"github.com/emersion/go-imap"

	"git.sr.ht/~sircmpwn/aerc/worker/types"
@@ -51,12 +52,26 @@ func (imapw *IMAPWorker) handleReadMessages(msg *types.ReadMessages) {
		flags = []interface{}{imap.SeenFlag}
	}
	uids := toSeqSet(msg.Uids)
	if err := imapw.client.UidStore(uids, item, flags, nil); err != nil {
	emitErr := func(err error) {
		imapw.worker.PostMessage(&types.Error{
			Message: types.RespondTo(msg),
			Error:   err,
		}, nil)
	}
	if err := imapw.client.UidStore(uids, item, flags, nil); err != nil {
		emitErr(err)
		return
	}
	imapw.worker.PostMessage(&types.Done{types.RespondTo(msg)}, nil)
	imapw.worker.PostAction(&types.FetchMessageHeaders{
		Uids: msg.Uids,
	}, func(msg types.WorkerMessage) {
		switch m := msg.(type) {
		case *types.Error:
			err := fmt.Errorf("handleReadMessages: %v", m.Error)
			imapw.worker.Logger.Printf("could not fetch headers: %s", err)
			emitErr(err)
		case *types.Done:
			imapw.worker.PostMessage(&types.Done{types.RespondTo(msg)}, nil)
		}
	})
}
-- 
2.25.0