~sircmpwn/aerc

Show spinner when fetching contents v1 PROPOSED

Thanks!

To git.sr.ht:~sircmpwn/aerc
   00b9ca5..d3379dd  master -> master
I actually ended up reverting this - it causes all of my messages to
disappear briefly whenever anything changes in my inbox.
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~sircmpwn/aerc/%3C20191002102412.56992-1-dev%40jeffas.io%3E/mbox | git am -3
Learn more about email & git

[PATCH] Show spinner when fetching contents Export this patch

The spinner should be shown when fetching the contents as we don't know
at that point whether there are some messages or not.
---
 lib/msgstore.go    | 9 ++++++---
 widgets/msglist.go | 3 +++
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/lib/msgstore.go b/lib/msgstore.go
index b0392ba..8cceed8 100644
--- a/lib/msgstore.go
+++ b/lib/msgstore.go
@@ -10,9 +10,10 @@ import (

 // Accesses to fields must be guarded by MessageStore.Lock/Unlock
 type MessageStore struct {
-	Deleted  map[uint32]interface{}
-	DirInfo  models.DirectoryInfo
-	Messages map[uint32]*models.MessageInfo
+	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 {
diff --git a/widgets/msglist.go b/widgets/msglist.go
index 5c2d2f4..729b65f 100644
--- a/widgets/msglist.go
+++ b/widgets/msglist.go
@@ -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 (
--
2.23.0
Thanks!

To git.sr.ht:~sircmpwn/aerc
   00b9ca5..d3379dd  master -> master
I actually ended up reverting this - it causes all of my messages to
disappear briefly whenever anything changes in my inbox.
View this thread in the archives