From 77c1a1714448092c2355eb1cc046f1939b46c5e4 Mon Sep 17 00:00:00 2001 From: Kevin Kuehler Date: Thu, 10 Oct 2019 15:27:11 -0700 Subject: 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 --- lib/msgstore.go | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) 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 { -- cgit v1.2.3