Show spinner when fetching contents

The spinner should be shown when fetching the contents as we don't know
at that point whether there are some messages or not.
This commit is contained in:
Jeffas 2019-10-02 11:24:12 +01:00 committed by Drew DeVault
parent 00b9ca5032
commit 1339faf788
2 changed files with 9 additions and 3 deletions

View file

@ -13,6 +13,7 @@ type MessageStore struct {
Deleted map[uint32]interface{}
DirInfo models.DirectoryInfo
Messages map[uint32]*models.MessageInfo
FetchingContents bool
// Ordered list of known UIDs
uids []uint32
@ -159,6 +160,7 @@ func (store *MessageStore) Update(msg types.WorkerMessage) {
store.worker.PostAction(&types.FetchDirectoryContents{
SortCriteria: store.defaultSortCriteria,
}, nil)
store.FetchingContents = true
update = true
case *types.DirectoryContents:
newMap := make(map[uint32]*models.MessageInfo)
@ -172,6 +174,7 @@ func (store *MessageStore) Update(msg types.WorkerMessage) {
}
store.Messages = newMap
store.uids = msg.Uids
store.FetchingContents = false
update = true
case *types.MessageInfo:
if existing, ok := store.Messages[msg.Info.Uid]; ok && existing != nil {

View file

@ -61,6 +61,9 @@ func (ml *MessageList) Draw(ctx *ui.Context) {
ml.drawEmptyMessage(ctx)
return
}
} else if store.FetchingContents {
ml.spinner.Draw(ctx)
return
}
var (