summaryrefslogtreecommitdiff
path: root/lib/msgstore.go
diff options
context:
space:
mode:
Diffstat (limited to 'lib/msgstore.go')
-rw-r--r--lib/msgstore.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/msgstore.go b/lib/msgstore.go
index 908f125..dc18137 100644
--- a/lib/msgstore.go
+++ b/lib/msgstore.go
@@ -208,6 +208,7 @@ func (store *MessageStore) Update(msg types.WorkerMessage) {
store.Messages = newMap
store.uids = msg.Uids
sort.SortBy(store.filtered, store.uids)
+ store.checkMark()
update = true
case *types.DirectoryThreaded:
var uids []uint32
@@ -228,6 +229,7 @@ func (store *MessageStore) Update(msg types.WorkerMessage) {
}
store.Messages = newMap
store.uids = uids
+ store.checkMark()
store.Threads = msg.Threads
update = true
case *types.MessageInfo:
@@ -572,6 +574,22 @@ func (store *MessageStore) resetMark() {
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
func (store *MessageStore) IsMarked(uid uint32) bool {
_, marked := store.marked[uid]