diff options
Diffstat (limited to 'commands/account')
-rw-r--r-- | commands/account/search.go | 17 | ||||
-rw-r--r-- | commands/account/sort.go | 6 |
2 files changed, 14 insertions, 9 deletions
diff --git a/commands/account/search.go b/commands/account/search.go index 771c850..7cae227 100644 --- a/commands/account/search.go +++ b/commands/account/search.go @@ -6,6 +6,7 @@ import ( "git.sr.ht/~rjarry/aerc/lib/statusline" "git.sr.ht/~rjarry/aerc/widgets" + "git.sr.ht/~rjarry/aerc/worker/types" ) type SearchFilter struct{} @@ -32,27 +33,29 @@ func (SearchFilter) Execute(aerc *widgets.Aerc, args []string) error { return errors.New("Cannot perform action. Messages still loading") } - var cb func([]uint32) if args[0] == "filter" { if len(args[1:]) == 0 { return Clear{}.Execute(aerc, []string{"clear"}) } acct.SetStatus(statusline.FilterActivity("Filtering..."), statusline.Search("")) - cb = func(uids []uint32) { - acct.SetStatus(statusline.FilterResult(strings.Join(args, " "))) - acct.Logger().Printf("Filter results: %v", uids) - store.ApplyFilter(uids) + store.SetFilter(args[1:]) + cb := func(msg types.WorkerMessage) { + if _, ok := msg.(*types.Done); ok { + acct.SetStatus(statusline.FilterResult(strings.Join(args, " "))) + acct.Logger().Printf("Filter results: %v", store.Uids()) + } } + store.Sort(nil, cb) } else { acct.SetStatus(statusline.Search("Searching...")) - cb = func(uids []uint32) { + cb := func(uids []uint32) { acct.SetStatus(statusline.Search(strings.Join(args, " "))) acct.Logger().Printf("Search results: %v", uids) store.ApplySearch(uids) // TODO: Remove when stores have multiple OnUpdate handlers acct.Messages().Invalidate() } + store.Search(args, cb) } - store.Search(args, cb) return nil } diff --git a/commands/account/sort.go b/commands/account/sort.go index a35ff33..e9ee4a3 100644 --- a/commands/account/sort.go +++ b/commands/account/sort.go @@ -84,8 +84,10 @@ func (Sort) Execute(aerc *widgets.Aerc, args []string) error { } acct.SetStatus(statusline.Sorting(true)) - store.Sort(sortCriteria, func() { - acct.SetStatus(statusline.Sorting(false)) + store.Sort(sortCriteria, func(msg types.WorkerMessage) { + if _, ok := msg.(*types.Done); ok { + acct.SetStatus(statusline.Sorting(false)) + } }) return nil } |