diff options
author | Kevin Kuehler <keur@xcf.berkeley.edu> | 2019-10-28 12:07:00 -0700 |
---|---|---|
committer | Ben Burwell <ben@benburwell.com> | 2019-10-29 11:07:21 -0400 |
commit | dca84afbbb050e21214b921ddd50eebc5c690435 (patch) | |
tree | 5cee9fd2328c7a67065e5c6f4b231f83ced257e4 /lib/msgstore.go | |
parent | 310bec27024579e7ada35585b3190ab875540804 (diff) |
Start adding thread support
* Add threading-enabled config option
* Add DirectoryThreaded and FetchDirectoryThreaded types to control path
* Add generic thread type for all backends to use
Signed-off-by: Kevin Kuehler <keur@xcf.berkeley.edu>
Diffstat (limited to 'lib/msgstore.go')
-rw-r--r-- | lib/msgstore.go | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/lib/msgstore.go b/lib/msgstore.go index 56d9eda..c0e4136 100644 --- a/lib/msgstore.go +++ b/lib/msgstore.go @@ -21,6 +21,9 @@ type MessageStore struct { bodyCallbacks map[uint32][]func(io.Reader) headerCallbacks map[uint32][]func(*types.MessageInfo) + // If set, messages in the mailbox will be threaded + thread bool + // Search/filter results results []uint32 resultIndex int @@ -42,6 +45,7 @@ type MessageStore struct { func NewMessageStore(worker *types.Worker, dirInfo *models.DirectoryInfo, defaultSortCriteria []*types.SortCriterion, + thread bool, triggerNewEmail func(*models.MessageInfo), triggerDirectoryChange func()) *MessageStore { @@ -53,6 +57,8 @@ func NewMessageStore(worker *types.Worker, bodyCallbacks: make(map[uint32][]func(io.Reader)), headerCallbacks: make(map[uint32][]func(*types.MessageInfo)), + thread: thread, + defaultSortCriteria: defaultSortCriteria, pendingBodies: make(map[uint32]interface{}), @@ -157,9 +163,15 @@ func (store *MessageStore) Update(msg types.WorkerMessage) { switch msg := msg.(type) { case *types.DirectoryInfo: store.DirInfo = *msg.Info - store.worker.PostAction(&types.FetchDirectoryContents{ - SortCriteria: store.defaultSortCriteria, - }, nil) + if store.thread { + store.worker.PostAction(&types.FetchDirectoryThreaded{ + SortCriteria: store.defaultSortCriteria, + }, nil) + } else { + store.worker.PostAction(&types.FetchDirectoryContents{ + SortCriteria: store.defaultSortCriteria, + }, nil) + } update = true case *types.DirectoryContents: newMap := make(map[uint32]*models.MessageInfo) |