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>
This commit is contained in:
parent
50992cb9e6
commit
cd72812781
1 changed files with 31 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue