diff options
author | Koni Marti <koni.marti@gmail.com> | 2023-05-22 23:52:41 +0200 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2023-05-28 18:21:26 +0200 |
commit | 792839b9a3196b3a8f1c57a2ced64e064061b9f9 (patch) | |
tree | dbd2867a90ce4435cb1fe5a88c7582201b2c98ec /lib/messageview.go | |
parent | 345907914f3e7f131ff9a0fd054a6f772d050636 (diff) | |
download | aerc-792839b9a3196b3a8f1c57a2ced64e064061b9f9.tar.gz |
lib: don't set seen flag upon error
Don't set the Seen flag when an error occurs during opening the message.
Fixes: https://todo.sr.ht/~rjarry/aerc/125
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Tested-by: Moritz Poldrack <moritz@poldrack.dev>
Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'lib/messageview.go')
-rw-r--r-- | lib/messageview.go | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/messageview.go b/lib/messageview.go index d0754cc1..f2d30086 100644 --- a/lib/messageview.go +++ b/lib/messageview.go @@ -70,14 +70,22 @@ type MessageStoreView struct { func NewMessageStoreView(messageInfo *models.MessageInfo, setSeen bool, store *MessageStore, pgp crypto.Provider, decryptKeys openpgp.PromptFunction, - cb func(MessageView, error), + innerCb func(MessageView, error), ) { + cb := func(msv MessageView, err error) { + if msv != nil && setSeen && err == nil { + store.Flag([]uint32{messageInfo.Uid}, models.SeenFlag, true, nil) + } + innerCb(msv, err) + } + if messageInfo == nil { // Call nils to the callback, the split view will use this to // display an empty view cb(nil, nil) return } + msv := &MessageStoreView{ messageInfo, store, nil, nil, messageInfo.BodyStructure, @@ -114,9 +122,6 @@ func NewMessageStoreView(messageInfo *models.MessageInfo, setSeen bool, } else { cb(msv, nil) } - if setSeen { - store.Flag([]uint32{messageInfo.Uid}, models.SeenFlag, true, nil) - } } func (msv *MessageStoreView) SeenFlagSet() bool { |