diff options
author | Drew DeVault <sir@cmpwn.com> | 2019-03-20 23:23:38 -0400 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2019-03-20 23:23:38 -0400 |
commit | 312a53e5ff721e0a29e34aaeceb0eece1203002d (patch) | |
tree | fb0c5f30d89f904d5fad4a900c910a1dd1d891be /widgets | |
parent | f3d3e0ed4f5dbf36b7a7c9762e6297083843f127 (diff) | |
download | aerc-312a53e5ff721e0a29e34aaeceb0eece1203002d.tar.gz |
Implement :delete-message
Diffstat (limited to 'widgets')
-rw-r--r-- | widgets/account.go | 3 | ||||
-rw-r--r-- | widgets/msglist.go | 20 |
2 files changed, 23 insertions, 0 deletions
diff --git a/widgets/account.go b/widgets/account.go index 8a3b989..f42ff6c 100644 --- a/widgets/account.go +++ b/widgets/account.go @@ -176,6 +176,9 @@ func (acct *AccountView) onMessage(msg types.WorkerMessage) { case *types.MessageInfo: store := acct.msgStores[acct.dirlist.selected] store.Update(msg) + case *types.MessagesDeleted: + store := acct.msgStores[acct.dirlist.selected] + store.Update(msg) case *types.Error: acct.logger.Printf("%v", msg.Error) acct.host.SetStatus(fmt.Sprintf("%v", msg.Error)). 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 { |