Skip to content

Commit

Permalink
commands: allow to reply to eml
Browse files Browse the repository at this point in the history
Reply to messages in the message viewer that were opened with :eml (e.g.
rfc822 attachments). Those messages have no associated message store and
currently :reply would complain about that.

However, we can still use the message data to create a reply, but we
would have to disable setting the replied flag and/or archiving messages
(obviously, these operations don't make sense for such messages in the
first place).

Implements: https://todo.sr.ht/~rjarry/aerc/227
Signed-off-by: Koni Marti <[email protected]>
Acked-by: Robin Jarry <[email protected]>
  • Loading branch information
konimarti authored and rjarry committed Feb 14, 2024
1 parent 2927516 commit 6afc2d5
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions commands/msg/reply.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,6 @@ func (r reply) Execute(args []string) error {
}
conf := acct.AccountConfig()

store := widget.Store()
if store == nil {
return errors.New("Cannot perform action. Messages still loading")
}
msg, err := widget.SelectedMessage()
if err != nil {
return err
Expand Down Expand Up @@ -157,6 +153,15 @@ func (r reply) Execute(args []string) error {
}

mv, isMsgViewer := app.SelectedTabContent().(*app.MessageViewer)

store := widget.Store()
noStore := store == nil
if noStore && isMsgViewer {
app.PushWarning("No message store found: answered flag cannot be set")
} else if noStore {
return errors.New("Cannot perform action. Messages still loading")
}

addTab := func() error {
composer, err := app.NewComposer(acct,
acct.AccountConfig(), acct.Worker(), editHeaders,
Expand All @@ -177,13 +182,13 @@ func (r reply) Execute(args []string) error {

composer.OnClose(func(c *app.Composer) {
switch {
case c.Sent() && c.Archive() != "":
case c.Sent() && c.Archive() != "" && !noStore:
store.Answered([]uint32{msg.Uid}, true, nil)
err := archive([]*models.MessageInfo{msg}, c.Archive())
if err != nil {
app.PushStatus("Archive failed", 10*time.Second)
}
case c.Sent():
case c.Sent() && !noStore:
store.Answered([]uint32{msg.Uid}, true, nil)
case mv != nil && r.Close:
view := account.ViewMessage{Peek: true}
Expand Down

0 comments on commit 6afc2d5

Please sign in to comment.