aboutsummaryrefslogtreecommitdiff
path: root/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'widgets')
-rw-r--r--widgets/msglist.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/widgets/msglist.go b/widgets/msglist.go
index 4f853f3..eeadec7 100644
--- a/widgets/msglist.go
+++ b/widgets/msglist.go
@@ -53,6 +53,8 @@ func (ml *MessageList) Draw(ctx *ui.Context) {
return
}
+ store.Lock()
+
var (
needsHeaders []uint32
row int = 0
@@ -92,6 +94,8 @@ func (ml *MessageList) Draw(ctx *ui.Context) {
tcell.StyleDefault, "%s", msg)
}
+ store.Unlock()
+
if len(needsHeaders) != 0 {
store.FetchHeaders(needsHeaders, nil)
ml.spinner.Start()
@@ -109,11 +113,13 @@ func (ml *MessageList) storeUpdate(store *lib.MessageStore) {
return
}
+ store.Lock()
if len(store.Uids) > 0 {
for ml.selected >= len(store.Uids) {
ml.Prev()
}
}
+ store.Unlock()
ml.Invalidate()
}
@@ -139,16 +145,25 @@ func (ml *MessageList) Store() *lib.MessageStore {
func (ml *MessageList) Empty() bool {
store := ml.Store()
+ store.Lock()
+ defer store.Unlock()
+
return store == nil || len(store.Uids) == 0
}
func (ml *MessageList) Selected() *types.MessageInfo {
store := ml.Store()
+ store.Lock()
+ defer store.Unlock()
+
return store.Messages[store.Uids[len(store.Uids)-ml.selected-1]]
}
func (ml *MessageList) Select(index int) {
store := ml.Store()
+ store.Lock()
+ defer store.Unlock()
+
ml.selected = index
for ; ml.selected < 0; ml.selected = len(store.Uids) + ml.selected {
}
@@ -166,6 +181,9 @@ func (ml *MessageList) Select(index int) {
func (ml *MessageList) nextPrev(delta int) {
store := ml.Store()
+ store.Lock()
+ defer store.Unlock()
+
if store == nil || len(store.Uids) == 0 {
return
}