viewer: option to not mark message as seen
Add option to open a message in the message viewer without setting the seen flag. Enables the message viewer to be used as a preview pane without changing the message flags unintentionally. Before, the message viewer would set the seen flag by default. The IMAP backend will now always fetch the message body with the peek option enabled (same as we fetch the headers). An "auto-mark-read" option is added to the ui config which is set to true by default. If set the false, the seen flag is not set by the message viewer. Co-authored-by: "James Cook" <falsifian@falsifian.org> Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
This commit is contained in:
parent
4c371170c5
commit
e4d418eed1
11 changed files with 33 additions and 10 deletions
|
@ -45,7 +45,8 @@ func (ViewMessage) Execute(aerc *widgets.Aerc, args []string) error {
|
|||
aerc.PushError(msg.Error.Error())
|
||||
return nil
|
||||
}
|
||||
lib.NewMessageStoreView(msg, store, aerc.Crypto, aerc.DecryptKeys,
|
||||
lib.NewMessageStoreView(msg, acct.UiConfig().AutoMarkRead,
|
||||
store, aerc.Crypto, aerc.DecryptKeys,
|
||||
func(view lib.MessageView, err error) {
|
||||
if err != nil {
|
||||
aerc.PushError(err.Error())
|
||||
|
|
|
@ -120,7 +120,8 @@ func (Archive) Execute(aerc *widgets.Aerc, args []string) error {
|
|||
acct.Messages().Invalidate()
|
||||
return
|
||||
}
|
||||
lib.NewMessageStoreView(next, store, aerc.Crypto, aerc.DecryptKeys,
|
||||
lib.NewMessageStoreView(next, acct.UiConfig().AutoMarkRead,
|
||||
store, aerc.Crypto, aerc.DecryptKeys,
|
||||
func(view lib.MessageView, err error) {
|
||||
if err != nil {
|
||||
aerc.PushError(err.Error())
|
||||
|
|
|
@ -63,7 +63,8 @@ func (Delete) Execute(aerc *widgets.Aerc, args []string) error {
|
|||
acct.Messages().Invalidate()
|
||||
return
|
||||
}
|
||||
lib.NewMessageStoreView(next, store, aerc.Crypto, aerc.DecryptKeys,
|
||||
lib.NewMessageStoreView(next, acct.UiConfig().AutoMarkRead,
|
||||
store, aerc.Crypto, aerc.DecryptKeys,
|
||||
func(view lib.MessageView, err error) {
|
||||
if err != nil {
|
||||
aerc.PushError(err.Error())
|
||||
|
|
|
@ -137,7 +137,8 @@ func (Recall) Execute(aerc *widgets.Aerc, args []string) error {
|
|||
})
|
||||
}
|
||||
|
||||
lib.NewMessageStoreView(msgInfo, store, aerc.Crypto, aerc.DecryptKeys,
|
||||
lib.NewMessageStoreView(msgInfo, acct.UiConfig().AutoMarkRead,
|
||||
store, aerc.Crypto, aerc.DecryptKeys,
|
||||
func(msg lib.MessageView, err error) {
|
||||
if err != nil {
|
||||
aerc.PushError(err.Error())
|
||||
|
|
|
@ -42,7 +42,8 @@ func (NextPrevMsg) Execute(aerc *widgets.Aerc, args []string) error {
|
|||
aerc.RemoveTab(mv)
|
||||
return nil
|
||||
}
|
||||
lib.NewMessageStoreView(nextMsg, store, aerc.Crypto, aerc.DecryptKeys,
|
||||
lib.NewMessageStoreView(nextMsg, acct.UiConfig().AutoMarkRead,
|
||||
store, aerc.Crypto, aerc.DecryptKeys,
|
||||
func(view lib.MessageView, err error) {
|
||||
if err != nil {
|
||||
aerc.PushError(err.Error())
|
||||
|
|
|
@ -130,6 +130,12 @@ sort=
|
|||
# Default: true
|
||||
next-message-on-delete=true
|
||||
|
||||
# Automatically set the "seen" flag when a message is opened in the message
|
||||
# viewer.
|
||||
#
|
||||
# Default: true
|
||||
auto-mark-read=true
|
||||
|
||||
# The directories where the stylesets are stored. It takes a colon-separated
|
||||
# list of directories. If this is unset or if a styleset cannot be found, the
|
||||
# following paths will be used as a fallback in that order:
|
||||
|
|
|
@ -33,6 +33,7 @@ type GeneralConfig struct {
|
|||
}
|
||||
|
||||
type UIConfig struct {
|
||||
AutoMarkRead bool `ini:"auto-mark-read"`
|
||||
IndexFormat string `ini:"index-format"`
|
||||
TimestampFormat string `ini:"timestamp-format"`
|
||||
ThisDayTimeFormat string `ini:"this-day-time-format"`
|
||||
|
@ -746,6 +747,7 @@ func LoadConfigFromFile(root *string, accts []string) (*AercConfig, error) {
|
|||
},
|
||||
|
||||
Ui: UIConfig{
|
||||
AutoMarkRead: true,
|
||||
IndexFormat: "%-20.20D %-17.17n %Z %s",
|
||||
TimestampFormat: "2006-01-02 03:04 PM",
|
||||
ThisDayTimeFormat: "",
|
||||
|
|
|
@ -218,6 +218,11 @@ These options are configured in the *[ui]* section of aerc.conf.
|
|||
|
||||
Default: true
|
||||
|
||||
*auto-mark-read*
|
||||
Set the "seen" flag when a message is opened in the message viewer.
|
||||
|
||||
Default: true
|
||||
|
||||
*completion-popovers*
|
||||
Shows potential auto-completions for text inputs in popovers.
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ type MessageStoreView struct {
|
|||
bodyStructure *models.BodyStructure
|
||||
}
|
||||
|
||||
func NewMessageStoreView(messageInfo *models.MessageInfo,
|
||||
func NewMessageStoreView(messageInfo *models.MessageInfo, setSeen bool,
|
||||
store *MessageStore, pgp crypto.Provider, decryptKeys openpgp.PromptFunction,
|
||||
cb func(MessageView, error),
|
||||
) {
|
||||
|
@ -97,8 +97,10 @@ func NewMessageStoreView(messageInfo *models.MessageInfo,
|
|||
} else {
|
||||
cb(msv, nil)
|
||||
}
|
||||
if setSeen {
|
||||
store.Flag([]uint32{messageInfo.Uid}, models.SeenFlag, true, nil)
|
||||
}
|
||||
}
|
||||
|
||||
func (msv *MessageStoreView) MessageInfo() *models.MessageInfo {
|
||||
return msv.messageInfo
|
||||
|
|
|
@ -308,8 +308,8 @@ func (ml *MessageList) MouseEvent(localX int, localY int, event tcell.Event) {
|
|||
if msg == nil {
|
||||
return
|
||||
}
|
||||
lib.NewMessageStoreView(msg, store, ml.aerc.Crypto,
|
||||
ml.aerc.DecryptKeys,
|
||||
lib.NewMessageStoreView(msg, acct.UiConfig().AutoMarkRead,
|
||||
store, ml.aerc.Crypto, ml.aerc.DecryptKeys,
|
||||
func(view lib.MessageView, err error) {
|
||||
if err != nil {
|
||||
ml.aerc.PushError(err.Error())
|
||||
|
|
|
@ -94,6 +94,7 @@ func (imapw *IMAPWorker) handleFetchMessageBodyPart(
|
|||
partBodySection.Specifier = imap.TextSpecifier
|
||||
}
|
||||
partBodySection.Path = msg.Part
|
||||
partBodySection.Peek = true
|
||||
|
||||
items := []imap.FetchItem{
|
||||
imap.FetchEnvelope,
|
||||
|
@ -150,7 +151,9 @@ func (imapw *IMAPWorker) handleFetchFullMessages(
|
|||
msg *types.FetchFullMessages,
|
||||
) {
|
||||
logging.Infof("Fetching full messages: %v", msg.Uids)
|
||||
section := &imap.BodySectionName{}
|
||||
section := &imap.BodySectionName{
|
||||
Peek: true,
|
||||
}
|
||||
items := []imap.FetchItem{
|
||||
imap.FetchEnvelope,
|
||||
imap.FetchFlags,
|
||||
|
|
Loading…
Reference in a new issue