imap: emit messageinfo when changing read state.
We need to emit the changed msgInfo whenever we modify the state
This commit is contained in:
parent
b2fa5a16f5
commit
df5d9a3ec7
1 changed files with 17 additions and 2 deletions
|
@ -1,6 +1,7 @@
|
||||||
package imap
|
package imap
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"github.com/emersion/go-imap"
|
"github.com/emersion/go-imap"
|
||||||
|
|
||||||
"git.sr.ht/~sircmpwn/aerc/worker/types"
|
"git.sr.ht/~sircmpwn/aerc/worker/types"
|
||||||
|
@ -51,12 +52,26 @@ func (imapw *IMAPWorker) handleReadMessages(msg *types.ReadMessages) {
|
||||||
flags = []interface{}{imap.SeenFlag}
|
flags = []interface{}{imap.SeenFlag}
|
||||||
}
|
}
|
||||||
uids := toSeqSet(msg.Uids)
|
uids := toSeqSet(msg.Uids)
|
||||||
if err := imapw.client.UidStore(uids, item, flags, nil); err != nil {
|
emitErr := func(err error) {
|
||||||
imapw.worker.PostMessage(&types.Error{
|
imapw.worker.PostMessage(&types.Error{
|
||||||
Message: types.RespondTo(msg),
|
Message: types.RespondTo(msg),
|
||||||
Error: err,
|
Error: err,
|
||||||
}, nil)
|
}, nil)
|
||||||
|
}
|
||||||
|
if err := imapw.client.UidStore(uids, item, flags, nil); err != nil {
|
||||||
|
emitErr(err)
|
||||||
return
|
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)
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue