diff options
author | Kevin Kuehler <keur@xcf.berkeley.edu> | 2019-10-10 15:27:11 -0700 |
---|---|---|
committer | Ben Burwell <ben@benburwell.com> | 2019-10-12 20:58:02 -0400 |
commit | 77c1a1714448092c2355eb1cc046f1939b46c5e4 (patch) | |
tree | 608fd54516ea57e44c0d14d8c7dc64daa09e73d0 /lib/msgstore.go | |
parent | d7f988f220a91a233eba97de89ffa549c968c63a (diff) |
lib/msgstore: Handle DirectoryThreaded msg
This method is called after a worker fetches a threaded directory
contents from the backend. We iterate over the threads in the same order
that they will be printed in the msglist.
Signed-off-by: Kevin Kuehler <keur@xcf.berkeley.edu>
Diffstat (limited to 'lib/msgstore.go')
-rw-r--r-- | lib/msgstore.go | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/lib/msgstore.go b/lib/msgstore.go index 064ad36..bfea081 100644 --- a/lib/msgstore.go +++ b/lib/msgstore.go @@ -15,7 +15,8 @@ type MessageStore struct { DirInfo models.DirectoryInfo Messages map[uint32]*models.MessageInfo // Ordered list of known UIDs - uids []uint32 + uids []uint32 + Threads []*types.Thread selected int bodyCallbacks map[uint32][]func(io.Reader) @@ -173,6 +174,27 @@ func (store *MessageStore) Update(msg types.WorkerMessage) { }, nil) } update = true + case *types.DirectoryThreaded: + var uids []uint32 + newMap := make(map[uint32]*models.MessageInfo) + + for i := len(msg.Threads) - 1; i >= 0; i-- { + msg.Threads[i].FormatThread(func(t *types.Thread, x string) bool { + uid := t.Uid + uids = append([]uint32{uid}, uids...) + if msg, ok := store.Messages[uid]; ok { + newMap[uid] = msg + } else { + newMap[uid] = nil + directoryChange = true + } + return false + }) + } + store.Messages = newMap + store.uids = uids + store.Threads = msg.Threads + update = true case *types.DirectoryContents: newMap := make(map[uint32]*models.MessageInfo) for _, uid := range msg.Uids { |