store: clean marked messages
Clean marked messages after new uids are fetched.
Commit 5c5158b3
("store: remove callbacks on error") removed side
effects in the message store after a longer suspend period but neglected
to remove marked zombie messages.
References: https://todo.sr.ht/~rjarry/aerc/28
Co-authored-by: inwit <inwit@sindominio.net>
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
This commit is contained in:
parent
461726802e
commit
30d5788974
1 changed files with 18 additions and 0 deletions
|
@ -208,6 +208,7 @@ func (store *MessageStore) Update(msg types.WorkerMessage) {
|
||||||
store.Messages = newMap
|
store.Messages = newMap
|
||||||
store.uids = msg.Uids
|
store.uids = msg.Uids
|
||||||
sort.SortBy(store.filtered, store.uids)
|
sort.SortBy(store.filtered, store.uids)
|
||||||
|
store.checkMark()
|
||||||
update = true
|
update = true
|
||||||
case *types.DirectoryThreaded:
|
case *types.DirectoryThreaded:
|
||||||
var uids []uint32
|
var uids []uint32
|
||||||
|
@ -228,6 +229,7 @@ func (store *MessageStore) Update(msg types.WorkerMessage) {
|
||||||
}
|
}
|
||||||
store.Messages = newMap
|
store.Messages = newMap
|
||||||
store.uids = uids
|
store.uids = uids
|
||||||
|
store.checkMark()
|
||||||
store.Threads = msg.Threads
|
store.Threads = msg.Threads
|
||||||
update = true
|
update = true
|
||||||
case *types.MessageInfo:
|
case *types.MessageInfo:
|
||||||
|
@ -572,6 +574,22 @@ func (store *MessageStore) resetMark() {
|
||||||
store.marked = make(map[uint32]struct{})
|
store.marked = make(map[uint32]struct{})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// checkMark checks that no stale uids remain marked
|
||||||
|
func (store *MessageStore) checkMark() {
|
||||||
|
for mark := range store.marked {
|
||||||
|
present := false
|
||||||
|
for _, uid := range store.uids {
|
||||||
|
if mark == uid {
|
||||||
|
present = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !present {
|
||||||
|
delete(store.marked, mark)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//IsMarked checks whether a MessageInfo has been marked
|
//IsMarked checks whether a MessageInfo has been marked
|
||||||
func (store *MessageStore) IsMarked(uid uint32) bool {
|
func (store *MessageStore) IsMarked(uid uint32) bool {
|
||||||
_, marked := store.marked[uid]
|
_, marked := store.marked[uid]
|
||||||
|
|
Loading…
Reference in a new issue