diff options
Diffstat (limited to 'commands')
-rw-r--r-- | commands/msg/archive.go | 32 |
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 |