Don't show empty message while sorting
This changes the ui to show the spinner while we are sorting. It only shows one line of the spinner since there are an unknown number of messages at this time.
This commit is contained in:
parent
2a0430ab90
commit
b55813f2c0
|
@ -14,6 +14,8 @@ type MessageStore struct {
|
||||||
Deleted map[uint32]interface{}
|
Deleted map[uint32]interface{}
|
||||||
DirInfo models.DirectoryInfo
|
DirInfo models.DirectoryInfo
|
||||||
Messages map[uint32]*models.MessageInfo
|
Messages map[uint32]*models.MessageInfo
|
||||||
|
Sorting bool
|
||||||
|
|
||||||
// Ordered list of known UIDs
|
// Ordered list of known UIDs
|
||||||
uids []uint32
|
uids []uint32
|
||||||
|
|
||||||
|
@ -185,9 +187,7 @@ func (store *MessageStore) Update(msg types.WorkerMessage) {
|
||||||
switch msg := msg.(type) {
|
switch msg := msg.(type) {
|
||||||
case *types.DirectoryInfo:
|
case *types.DirectoryInfo:
|
||||||
store.DirInfo = *msg.Info
|
store.DirInfo = *msg.Info
|
||||||
store.worker.PostAction(&types.FetchDirectoryContents{
|
store.Sort(store.defaultSortCriteria, nil)
|
||||||
SortCriteria: store.defaultSortCriteria,
|
|
||||||
}, nil)
|
|
||||||
update = true
|
update = true
|
||||||
case *types.DirectoryContents:
|
case *types.DirectoryContents:
|
||||||
newMap := make(map[uint32]*models.MessageInfo)
|
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()) {
|
func (store *MessageStore) Sort(criteria []*types.SortCriterion, cb func()) {
|
||||||
|
store.Sorting = true
|
||||||
store.worker.PostAction(&types.FetchDirectoryContents{
|
store.worker.PostAction(&types.FetchDirectoryContents{
|
||||||
SortCriteria: criteria,
|
SortCriteria: criteria,
|
||||||
}, func(msg types.WorkerMessage) {
|
}, func(msg types.WorkerMessage) {
|
||||||
cb()
|
store.Sorting = false
|
||||||
|
if cb != nil {
|
||||||
|
cb()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,6 +63,12 @@ func (ml *MessageList) Draw(ctx *ui.Context) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if store.Sorting {
|
||||||
|
ml.spinner.Start()
|
||||||
|
ml.spinner.Draw(ctx)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
needsHeaders []uint32
|
needsHeaders []uint32
|
||||||
row int = 0
|
row int = 0
|
||||||
|
|
Loading…
Reference in New Issue