aboutsummaryrefslogtreecommitdiffstats
path: root/commands/msg/archive.go
diff options
context:
space:
mode:
authorBen Cohen <ben@bencohen.net>2022-08-22 12:20:17 -0400
committerRobin Jarry <robin@jarry.cc>2022-08-22 20:33:28 +0200
commitcd72812781cdfb5f12adfa10546ed2a6481ec6e4 (patch)
tree7364e3a00dc693632acf6e19bcb5b31f19633eb4 /commands/msg/archive.go
parent50992cb9e654d4385a909433bcff08fdbe3a67ec (diff)
downloadaerc-cd72812781cdfb5f12adfa10546ed2a6481ec6e4.tar.gz
archive: respect the next-message-on-delete flag
Reuse the next-message-on-delete configuration flag to mirror the behavior of delete when archiving. Signed-off-by: Ben Cohen <ben@bencohen.net> Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'commands/msg/archive.go')
-rw-r--r--commands/msg/archive.go32
1 files changed, 31 insertions, 1 deletions
diff --git a/commands/msg/archive.go b/commands/msg/archive.go
index f359f43b..f7baff01 100644
--- a/commands/msg/archive.go
+++ b/commands/msg/archive.go
@@ -8,6 +8,7 @@ import (
"time"
"git.sr.ht/~rjarry/aerc/commands"
+ "git.sr.ht/~rjarry/aerc/lib"
"git.sr.ht/~rjarry/aerc/logging"
"git.sr.ht/~rjarry/aerc/models"
"git.sr.ht/~rjarry/aerc/widgets"
@@ -59,7 +60,7 @@ func (Archive) Execute(aerc *widgets.Aerc, args []string) error {
}
marker := store.Marker()
marker.ClearVisualMark()
- findNextNonDeleted(uids, store)
+ next := findNextNonDeleted(uids, store)
var uidMap map[string][]uint32
switch args[1] {
@@ -107,6 +108,35 @@ func (Archive) Execute(aerc *widgets.Aerc, args []string) error {
wg.Wait()
if success {
aerc.PushStatus("Messages archived.", 10*time.Second)
+ mv, isMsgView := h.msgProvider.(*widgets.MessageViewer)
+ if isMsgView {
+ if !aerc.Config().Ui.NextMessageOnDelete {
+ aerc.RemoveTab(h.msgProvider)
+ } else {
+ // no more messages in the list
+ if next == nil {
+ aerc.RemoveTab(h.msgProvider)
+ acct.Messages().Select(-1)
+ acct.Messages().Invalidate()
+ return
+ }
+ lib.NewMessageStoreView(next, store, aerc.Crypto, aerc.DecryptKeys,
+ func(view lib.MessageView, err error) {
+ if err != nil {
+ aerc.PushError(err.Error())
+ return
+ }
+ nextMv := widgets.NewMessageViewer(acct, aerc.Config(), view)
+ aerc.ReplaceTab(mv, nextMv, next.Envelope.Subject)
+ })
+ }
+ } else {
+ if next == nil {
+ // We archived the last message, select the new last message
+ // instead of the first message
+ acct.Messages().Select(-1)
+ }
+ }
}
}()
return nil