notmuch: fix cursor movement in threaded view

Set the SkipSort flag when sending directory infos for counting
purposes. Without this, the directory infos would trigger a directory
fetch which could bring the notmuch threads out of sync with the message
list. The notmuch backend sends these directory infos automatically
every minute.

To reproduce the weird cursor movement in notmuch's threaded view:
1. enter threaded view in notmuch
2. wait 1 min (until the auto directory infos are sent out)
3. move cursor around and notice how it jumps over threads

Signed-off-by: Koni Marti <koni.marti@gmail.com>
Tested-by: Tim Culverhouse <tim@timculverhouse.com>
This commit is contained in:
Koni Marti 2022-07-30 17:36:56 +02:00 committed by Robin Jarry
parent 27425c15c4
commit 318f7d252c
2 changed files with 7 additions and 1 deletions

View File

@ -16,7 +16,7 @@ func (w *worker) handleNotmuchEvent(et eventType) error {
func (w *worker) handleUpdateDirCounts(ev eventType) error {
for name, query := range w.nameQueryMap {
info, err := w.gatherDirectoryInfo(name, query)
info, err := w.buildDirInfo(name, query, true)
if err != nil {
logging.Errorf("could not gather DirectoryInfo: %v", err)
continue

View File

@ -211,12 +211,18 @@ func (w *worker) handleListDirectories(msg *types.ListDirectories) error {
}
func (w *worker) gatherDirectoryInfo(name string, query string) (
*types.DirectoryInfo, error) {
return w.buildDirInfo(name, query, false)
}
func (w *worker) buildDirInfo(name string, query string, skipSort bool) (
*types.DirectoryInfo, error) {
count, err := w.db.QueryCountMessages(query)
if err != nil {
return nil, err
}
info := &types.DirectoryInfo{
SkipSort: skipSort,
Info: &models.DirectoryInfo{
Name: name,
Flags: []string{},