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:
parent
380cf13cff
commit
f530cd96f3
1 changed files with 7 additions and 4 deletions
|
@ -188,6 +188,7 @@ func merge(to *models.MessageInfo, from *models.MessageInfo) {
|
|||
|
||||
func (store *MessageStore) Update(msg types.WorkerMessage) {
|
||||
update := false
|
||||
updateThreads := false
|
||||
directoryChange := false
|
||||
switch msg := msg.(type) {
|
||||
case *types.DirectoryInfo:
|
||||
|
@ -255,6 +256,7 @@ func (store *MessageStore) Update(msg types.WorkerMessage) {
|
|||
store.builder.Update(msg.Info)
|
||||
}
|
||||
update = true
|
||||
updateThreads = true
|
||||
case *types.FullMessage:
|
||||
if _, ok := store.pendingBodies[msg.Content.Uid]; ok {
|
||||
delete(store.pendingBodies, msg.Content.Uid)
|
||||
|
@ -305,10 +307,11 @@ func (store *MessageStore) Update(msg types.WorkerMessage) {
|
|||
}
|
||||
|
||||
update = true
|
||||
updateThreads = true
|
||||
}
|
||||
|
||||
if update {
|
||||
store.update()
|
||||
store.update(updateThreads)
|
||||
}
|
||||
|
||||
if directoryChange && store.triggerDirectoryChange != nil {
|
||||
|
@ -328,14 +331,14 @@ func (store *MessageStore) OnUpdateDirs(fn func()) {
|
|||
store.onUpdateDirs = fn
|
||||
}
|
||||
|
||||
func (store *MessageStore) update() {
|
||||
func (store *MessageStore) update(threads bool) {
|
||||
if store.onUpdate != nil {
|
||||
store.onUpdate(store)
|
||||
}
|
||||
if store.onUpdateDirs != nil {
|
||||
store.onUpdateDirs()
|
||||
}
|
||||
if store.BuildThreads() && store.ThreadedView() {
|
||||
if store.BuildThreads() && store.ThreadedView() && threads {
|
||||
store.runThreadBuilder()
|
||||
}
|
||||
}
|
||||
|
@ -654,7 +657,7 @@ func (store *MessageStore) nextPrevResult(delta int) {
|
|||
store.resultIndex = len(store.results) - 1
|
||||
}
|
||||
store.Select(store.results[len(store.results)-store.resultIndex-1])
|
||||
store.update()
|
||||
store.update(false)
|
||||
}
|
||||
|
||||
func (store *MessageStore) NextResult() {
|
||||
|
|
Loading…
Reference in a new issue