aboutsummaryrefslogtreecommitdiff
path: root/widgets
diff options
context:
space:
mode:
authorJeffas <dev@jeffas.io>2019-09-19 23:37:44 +0100
committerDrew DeVault <sir@cmpwn.com>2019-09-20 14:56:02 -0400
commit90d26da58a4af2d34328f5916adf3781222966c6 (patch)
tree58a60e0d42b183f94d12b35e19ed1b046d03d5cd /widgets
parent43435ba06cd0820a83f14630881981b338473cb8 (diff)
Add sorting functionality
There is a command and config option. The criteria are a list of the sort criterion and each can be individually reversed. This only includes support for sorting in the maildir backend currently. The other backends are not supported in this patch.
Diffstat (limited to 'widgets')
-rw-r--r--widgets/account.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/widgets/account.go b/widgets/account.go
index eb6a495..4e8dd17 100644
--- a/widgets/account.go
+++ b/widgets/account.go
@@ -9,6 +9,7 @@ import (
"git.sr.ht/~sircmpwn/aerc/config"
"git.sr.ht/~sircmpwn/aerc/lib"
+ "git.sr.ht/~sircmpwn/aerc/lib/sort"
"git.sr.ht/~sircmpwn/aerc/lib/ui"
"git.sr.ht/~sircmpwn/aerc/models"
"git.sr.ht/~sircmpwn/aerc/worker"
@@ -218,6 +219,7 @@ func (acct *AccountView) onMessage(msg types.WorkerMessage) {
store.Update(msg)
} else {
store = lib.NewMessageStore(acct.worker, msg.Info,
+ acct.getSortCriteria(),
func(msg *models.MessageInfo) {
acct.conf.Triggers.ExecNewEmail(acct.acct,
acct.conf, msg)
@@ -254,3 +256,15 @@ func (acct *AccountView) onMessage(msg types.WorkerMessage) {
Color(tcell.ColorDefault, tcell.ColorRed)
}
}
+
+func (acct *AccountView) getSortCriteria() []*types.SortCriterion {
+ if len(acct.conf.Ui.Sort) == 0 {
+ return nil
+ }
+ criteria, err := sort.GetSortCriteria(acct.conf.Ui.Sort)
+ if err != nil {
+ acct.aerc.PushError(" ui.sort: " + err.Error())
+ return nil
+ }
+ return criteria
+}