diff options
-rw-r--r-- | lib/msgstore.go | 12 | ||||
-rw-r--r-- | widgets/msglist.go | 6 |
2 files changed, 14 insertions, 4 deletions
diff --git a/lib/msgstore.go b/lib/msgstore.go index b1785c14..709c7a28 100644 --- a/lib/msgstore.go +++ b/lib/msgstore.go @@ -14,6 +14,8 @@ type MessageStore struct { Deleted map[uint32]interface{} DirInfo models.DirectoryInfo Messages map[uint32]*models.MessageInfo + Sorting bool + // Ordered list of known UIDs uids []uint32 @@ -185,9 +187,7 @@ func (store *MessageStore) Update(msg types.WorkerMessage) { switch msg := msg.(type) { case *types.DirectoryInfo: store.DirInfo = *msg.Info - store.worker.PostAction(&types.FetchDirectoryContents{ - SortCriteria: store.defaultSortCriteria, - }, nil) + store.Sort(store.defaultSortCriteria, nil) update = true case *types.DirectoryContents: newMap := make(map[uint32]*models.MessageInfo) @@ -599,10 +599,14 @@ func (store *MessageStore) ModifyLabels(uids []uint32, add, remove []string, } func (store *MessageStore) Sort(criteria []*types.SortCriterion, cb func()) { + store.Sorting = true store.worker.PostAction(&types.FetchDirectoryContents{ SortCriteria: criteria, }, func(msg types.WorkerMessage) { - cb() + store.Sorting = false + if cb != nil { + cb() + } }) } diff --git a/widgets/msglist.go b/widgets/msglist.go index 51c133c0..59abf590 100644 --- a/widgets/msglist.go +++ b/widgets/msglist.go @@ -63,6 +63,12 @@ func (ml *MessageList) Draw(ctx *ui.Context) { } } + if store.Sorting { + ml.spinner.Start() + ml.spinner.Draw(ctx) + return + } + var ( needsHeaders []uint32 row int = 0 |