aboutsummaryrefslogtreecommitdiff
path: root/widgets/msglist.go
diff options
context:
space:
mode:
Diffstat (limited to 'widgets/msglist.go')
-rw-r--r--widgets/msglist.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/widgets/msglist.go b/widgets/msglist.go
index ab25847..ac941c8 100644
--- a/widgets/msglist.go
+++ b/widgets/msglist.go
@@ -8,6 +8,7 @@ import (
"git.sr.ht/~sircmpwn/aerc2/config"
"git.sr.ht/~sircmpwn/aerc2/lib"
"git.sr.ht/~sircmpwn/aerc2/lib/ui"
+ "git.sr.ht/~sircmpwn/aerc2/worker/types"
)
type MessageList struct {
@@ -98,6 +99,16 @@ func (ml *MessageList) Height() int {
return ml.height
}
+func (ml *MessageList) storeUpdate(store *lib.MessageStore) {
+ if ml.store != store {
+ return
+ }
+ for ml.selected >= len(ml.store.Uids) {
+ ml.Prev()
+ }
+ ml.Invalidate()
+}
+
func (ml *MessageList) SetStore(store *lib.MessageStore) {
if ml.store == store {
ml.scroll = 0
@@ -106,12 +117,21 @@ func (ml *MessageList) SetStore(store *lib.MessageStore) {
ml.store = store
if store != nil {
ml.spinner.Stop()
+ ml.store.OnUpdate(ml.storeUpdate)
} else {
ml.spinner.Start()
}
ml.Invalidate()
}
+func (ml *MessageList) Store() *lib.MessageStore {
+ return ml.store
+}
+
+func (ml *MessageList) Selected() *types.MessageInfo {
+ return ml.store.Messages[ml.store.Uids[len(ml.store.Uids)-ml.selected-1]]
+}
+
func (ml *MessageList) Select(index int) {
ml.selected = index
for ; ml.selected < 0; ml.selected = len(ml.store.Uids) + ml.selected {