diff options
author | Drew DeVault <sir@cmpwn.com> | 2019-03-30 10:40:55 -0400 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2019-03-30 10:41:12 -0400 |
commit | 4465646fedc5dd3efa680a7cc8d06671350b75b9 (patch) | |
tree | a00457017cd26aef80bdd78cfd02293a9292e40a /lib/msgstore.go | |
parent | 77ede6eb5a22a5407541ac587736189fcca0037f (diff) | |
download | aerc-4465646fedc5dd3efa680a7cc8d06671350b75b9.tar.gz |
Show deleted emails pending server ack in grey
TODO: Don't let the user select or interact with deleted messages
Diffstat (limited to 'lib/msgstore.go')
-rw-r--r-- | lib/msgstore.go | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/lib/msgstore.go b/lib/msgstore.go index be124df..3c77c49 100644 --- a/lib/msgstore.go +++ b/lib/msgstore.go @@ -8,6 +8,7 @@ import ( ) type MessageStore struct { + Deleted map[uint32]interface{} DirInfo types.DirectoryInfo Messages map[uint32]*types.MessageInfo // Ordered list of known UIDs @@ -27,6 +28,7 @@ func NewMessageStore(worker *types.Worker, dirInfo *types.DirectoryInfo) *MessageStore { return &MessageStore{ + Deleted: make(map[uint32]interface{}), DirInfo: *dirInfo, bodyCallbacks: make(map[uint32][]func(*mail.Message)), @@ -142,6 +144,9 @@ func (store *MessageStore) Update(msg types.WorkerMessage) { for _, uid := range msg.Uids { toDelete[uid] = nil delete(store.Messages, uid) + if _, ok := store.Deleted[uid]; ok { + delete(store.Deleted, uid) + } } uids := make([]uint32, len(store.Uids)-len(msg.Uids)) j := 0 @@ -154,8 +159,8 @@ func (store *MessageStore) Update(msg types.WorkerMessage) { store.Uids = uids update = true } - if update && store.onUpdate != nil { - store.onUpdate(store) + if update { + store.update() } } @@ -163,10 +168,18 @@ func (store *MessageStore) OnUpdate(fn func(store *MessageStore)) { store.onUpdate = fn } +func (store *MessageStore) update() { + if store.onUpdate != nil { + store.onUpdate(store) + } +} + func (store *MessageStore) Delete(uids []uint32) { var set imap.SeqSet for _, uid := range uids { set.AddNum(uid) + store.Deleted[uid] = nil } store.worker.PostAction(&types.DeleteMessages{Uids: set}, nil) + store.update() } |