diff options
author | Tim Culverhouse <tim@timculverhouse.com> | 2022-07-05 14:48:38 -0500 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2022-07-10 21:15:12 +0200 |
commit | 3a614e45fce9b505bb7e17a31eabffcc5e2d9022 (patch) | |
tree | 0074b0a5fdae73b98883fbe136ef290d5e014c90 /lib/msgstore.go | |
parent | f0c76fad7299c2c43f5891becd4f0327e0e26df5 (diff) | |
download | aerc-3a614e45fce9b505bb7e17a31eabffcc5e2d9022.tar.gz |
threading: enable toggle-threads for server-side threads
Enable the :toggle-threads command to work for workers which have Thread
capability. The implementation of that feature has the side effect that
the threading-enabled config option now sets the default view (threaded
or not threaded) for any worker, not just IMAP or notmuch.
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'lib/msgstore.go')
-rw-r--r-- | lib/msgstore.go | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/lib/msgstore.go b/lib/msgstore.go index 88089654..0eb5682a 100644 --- a/lib/msgstore.go +++ b/lib/msgstore.go @@ -38,7 +38,7 @@ type MessageStore struct { sortCriteria []*types.SortCriterion - thread bool + threadedView bool buildThreads bool builder *ThreadBuilder @@ -66,6 +66,11 @@ func NewMessageStore(worker *types.Worker, dirInfoUpdateDelay := 5 * time.Second + var clientThreads bool + if !dirInfo.Caps.Thread { + clientThreads = true + } + return &MessageStore{ Deleted: make(map[uint32]interface{}), DirInfo: *dirInfo, @@ -76,7 +81,8 @@ func NewMessageStore(worker *types.Worker, bodyCallbacks: make(map[uint32][]func(*types.FullMessage)), headerCallbacks: make(map[uint32][]func(*types.MessageInfo)), - thread: thread, + threadedView: thread, + buildThreads: clientThreads, sortCriteria: defaultSortCriteria, @@ -361,22 +367,22 @@ func (store *MessageStore) update() { } } -func (store *MessageStore) SetBuildThreads(buildThreads bool) { - // if worker provides threading, don't build our own threads - if store.thread { +func (store *MessageStore) SetThreadedView(thread bool) { + store.threadedView = thread + if store.buildThreads { + if store.threadedView { + store.runThreadBuilder() + } return } - store.buildThreads = buildThreads - if store.BuildThreads() { - store.runThreadBuilder() - } + store.Sort(store.sortCriteria, nil) +} + +func (store *MessageStore) ThreadedView() bool { + return store.threadedView } func (store *MessageStore) BuildThreads() bool { - // if worker provides threading, don't build our own threads - if store.thread { - return false - } return store.buildThreads } @@ -486,7 +492,7 @@ func (store *MessageStore) Answered(uids []uint32, answered bool, func (store *MessageStore) Uids() []uint32 { - if store.BuildThreads() && store.builder != nil { + if store.ThreadedView() && store.builder != nil { if uids := store.builder.Uids(); len(uids) > 0 { return uids } @@ -802,7 +808,7 @@ func (store *MessageStore) Sort(criteria []*types.SortCriterion, cb func()) { } } - if store.thread { + if store.threadedView && !store.buildThreads { store.worker.PostAction(&types.FetchDirectoryThreaded{ SortCriteria: criteria, }, handle_return) |