aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--commands/account/sort.go13
-rw-r--r--lib/msgstore.go7
-rw-r--r--widgets/account.go4
3 files changed, 16 insertions, 8 deletions
diff --git a/commands/account/sort.go b/commands/account/sort.go
index ad1a402d..c08991c8 100644
--- a/commands/account/sort.go
+++ b/commands/account/sort.go
@@ -7,6 +7,7 @@ import (
"git.sr.ht/~rjarry/aerc/commands"
"git.sr.ht/~rjarry/aerc/lib/sort"
"git.sr.ht/~rjarry/aerc/widgets"
+ "git.sr.ht/~rjarry/aerc/worker/types"
)
type Sort struct{}
@@ -70,9 +71,15 @@ func (Sort) Execute(aerc *widgets.Aerc, args []string) error {
return errors.New("Messages still loading.")
}
- sortCriteria, err := sort.GetSortCriteria(args[1:])
- if err != nil {
- return err
+ var err error
+ var sortCriteria []*types.SortCriterion
+ if len(args[1:]) == 0 {
+ sortCriteria = acct.GetSortCriteria()
+ } else {
+ sortCriteria, err = sort.GetSortCriteria(args[1:])
+ if err != nil {
+ return err
+ }
}
aerc.SetStatus("Sorting")
diff --git a/lib/msgstore.go b/lib/msgstore.go
index 0ded01fd..542f93de 100644
--- a/lib/msgstore.go
+++ b/lib/msgstore.go
@@ -35,7 +35,7 @@ type MessageStore struct {
filtered []uint32
filter bool
- defaultSortCriteria []*types.SortCriterion
+ sortCriteria []*types.SortCriterion
thread bool
buildThreads bool
@@ -77,7 +77,7 @@ func NewMessageStore(worker *types.Worker,
thread: thread,
- defaultSortCriteria: defaultSortCriteria,
+ sortCriteria: defaultSortCriteria,
pendingBodies: make(map[uint32]interface{}),
pendingHeaders: make(map[uint32]interface{}),
@@ -184,7 +184,7 @@ func (store *MessageStore) Update(msg types.WorkerMessage) {
switch msg := msg.(type) {
case *types.DirectoryInfo:
store.DirInfo = *msg.Info
- store.Sort(store.defaultSortCriteria, nil)
+ store.Sort(store.sortCriteria, nil)
update = true
case *types.DirectoryContents:
newMap := make(map[uint32]*models.MessageInfo)
@@ -721,6 +721,7 @@ func (store *MessageStore) ModifyLabels(uids []uint32, add, remove []string,
func (store *MessageStore) Sort(criteria []*types.SortCriterion, cb func()) {
store.Sorting = true
+ store.sortCriteria = criteria
handle_return := func(msg types.WorkerMessage) {
store.Sorting = false
diff --git a/widgets/account.go b/widgets/account.go
index 6cf49aa1..994bba6e 100644
--- a/widgets/account.go
+++ b/widgets/account.go
@@ -282,7 +282,7 @@ func (acct *AccountView) onMessage(msg types.WorkerMessage) {
store.Update(msg)
} else {
store = lib.NewMessageStore(acct.worker, msg.Info,
- acct.getSortCriteria(),
+ acct.GetSortCriteria(),
acct.UiConfig().ThreadingEnabled,
func(msg *models.MessageInfo) {
acct.conf.Triggers.ExecNewEmail(acct.acct,
@@ -335,7 +335,7 @@ func (acct *AccountView) onMessage(msg types.WorkerMessage) {
acct.UpdateStatus()
}
-func (acct *AccountView) getSortCriteria() []*types.SortCriterion {
+func (acct *AccountView) GetSortCriteria() []*types.SortCriterion {
if len(acct.UiConfig().Sort) == 0 {
return nil
}