aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorKevin Kuehler <keur@xcf.berkeley.edu>2019-10-10 15:27:13 -0700
committerBen Burwell <ben@benburwell.com>2019-10-12 20:58:10 -0400
commit287bf609554c5b0e9d82f28e89f6ca988b8fd452 (patch)
tree1a78451c00cd0055be679a0a0a0c14dc0056872c /lib
parentbaa8813dcc1bf4dbd18763df9ee654472ae0e433 (diff)
Add thread deletion
Signed-off-by: Kevin Kuehler <keur@xcf.berkeley.edu>
Diffstat (limited to 'lib')
-rw-r--r--lib/msgstore.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/msgstore.go b/lib/msgstore.go
index e86dc56..2adefda 100644
--- a/lib/msgstore.go
+++ b/lib/msgstore.go
@@ -158,6 +158,18 @@ func merge(to *models.MessageInfo, from *models.MessageInfo) {
}
}
+func (store *MessageStore) removeThread(threads []*types.Thread, needle *types.Thread) []*types.Thread {
+ var r []*types.Thread
+ for i, thread := range threads {
+ if thread.Uid == needle.Uid {
+ r = append(threads[:i], threads[i+1:]...)
+ r = append(r, needle.Children...)
+ break
+ }
+ }
+ return r
+}
+
func (store *MessageStore) Update(msg types.WorkerMessage) {
update := false
directoryChange := false
@@ -251,6 +263,18 @@ func (store *MessageStore) Update(msg types.WorkerMessage) {
toDelete[uid] = nil
delete(store.Messages, uid)
delete(store.Deleted, uid)
+ if store.thread {
+ for _, thread := range store.Threads {
+ if needle := thread.Find(uid); needle != nil {
+ if needle.Parent == nil {
+ store.Threads = store.removeThread(store.Threads, needle)
+ } else {
+ needle.Parent.Children = store.removeThread(needle.Parent.Children, needle)
+ }
+ break
+ }
+ }
+ }
}
uids := make([]uint32, len(store.uids)-len(msg.Uids))
j := 0