msgstore: enable granularity in updating of threadbuilder

Enable the msgstore to specify if an update should also update the
threadbuilder. Certain calls to msgstore.update() did not require the
threadbuilder to run, as it was either called implicitly through other
means (nextPrev during a search) OR it was not needed (IE in the case of
a DirectoryInfo message).

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
This commit is contained in:
Tim Culverhouse 2022-08-30 10:36:41 -05:00 committed by Robin Jarry
parent 380cf13cff
commit f530cd96f3

View file

@ -188,6 +188,7 @@ func merge(to *models.MessageInfo, from *models.MessageInfo) {
func (store *MessageStore) Update(msg types.WorkerMessage) { func (store *MessageStore) Update(msg types.WorkerMessage) {
update := false update := false
updateThreads := false
directoryChange := false directoryChange := false
switch msg := msg.(type) { switch msg := msg.(type) {
case *types.DirectoryInfo: case *types.DirectoryInfo:
@ -255,6 +256,7 @@ func (store *MessageStore) Update(msg types.WorkerMessage) {
store.builder.Update(msg.Info) store.builder.Update(msg.Info)
} }
update = true update = true
updateThreads = true
case *types.FullMessage: case *types.FullMessage:
if _, ok := store.pendingBodies[msg.Content.Uid]; ok { if _, ok := store.pendingBodies[msg.Content.Uid]; ok {
delete(store.pendingBodies, msg.Content.Uid) delete(store.pendingBodies, msg.Content.Uid)
@ -305,10 +307,11 @@ func (store *MessageStore) Update(msg types.WorkerMessage) {
} }
update = true update = true
updateThreads = true
} }
if update { if update {
store.update() store.update(updateThreads)
} }
if directoryChange && store.triggerDirectoryChange != nil { if directoryChange && store.triggerDirectoryChange != nil {
@ -328,14 +331,14 @@ func (store *MessageStore) OnUpdateDirs(fn func()) {
store.onUpdateDirs = fn store.onUpdateDirs = fn
} }
func (store *MessageStore) update() { func (store *MessageStore) update(threads bool) {
if store.onUpdate != nil { if store.onUpdate != nil {
store.onUpdate(store) store.onUpdate(store)
} }
if store.onUpdateDirs != nil { if store.onUpdateDirs != nil {
store.onUpdateDirs() store.onUpdateDirs()
} }
if store.BuildThreads() && store.ThreadedView() { if store.BuildThreads() && store.ThreadedView() && threads {
store.runThreadBuilder() store.runThreadBuilder()
} }
} }
@ -654,7 +657,7 @@ func (store *MessageStore) nextPrevResult(delta int) {
store.resultIndex = len(store.results) - 1 store.resultIndex = len(store.results) - 1
} }
store.Select(store.results[len(store.results)-store.resultIndex-1]) store.Select(store.results[len(store.results)-store.resultIndex-1])
store.update() store.update(false)
} }
func (store *MessageStore) NextResult() { func (store *MessageStore) NextResult() {