diff options
author | Tim Culverhouse <tim@timculverhouse.com> | 2022-12-07 13:38:04 -0600 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2022-12-14 11:24:49 +0100 |
commit | ffc21baeacb587f66e58ef65ddfdd40b0be4a812 (patch) | |
tree | 595016e06f55fbca06597c06fe495f47c35c8f73 | |
parent | fec207e92270f8ad176b85f43c46bc2926e1cd6c (diff) | |
download | aerc-ffc21baeacb587f66e58ef65ddfdd40b0be4a812.tar.gz |
threads: rebuild server threads when updating threads
The addition of the iterator factory added a thread builder when using
server side threads. A conditional for returning UIDs when selecting
messages would check for a not-nil store.builder, and return UIDs from
the thread builder. When using server side threads, there was no
mechanism to update the threads after a message deletion or move, so
store.Uids() would return a stale set of UIDs. This would allow the user
to "select" a deleted email (the cursor would disappear).
Add an update mechanism for the threads if server side threads are
enabled. When building thread UIDs, check for deleted or hidden threads.
Fixes: https://todo.sr.ht/~rjarry/aerc/123
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Tested-by: Inwit <inwit@sindominio.net>
-rw-r--r-- | lib/msgstore.go | 12 | ||||
-rw-r--r-- | lib/threadbuilder.go | 3 |
2 files changed, 13 insertions, 2 deletions
diff --git a/lib/msgstore.go b/lib/msgstore.go index 6710fa56..c02d8f4d 100644 --- a/lib/msgstore.go +++ b/lib/msgstore.go @@ -368,8 +368,16 @@ func (store *MessageStore) update(threads bool) { if store.onUpdateDirs != nil { store.onUpdateDirs() } - if store.BuildThreads() && store.ThreadedView() && threads { - store.runThreadBuilder() + if store.ThreadedView() && threads { + switch { + case store.BuildThreads(): + store.runThreadBuilder() + default: + if store.builder == nil { + store.builder = NewThreadBuilder(store.iterFactory) + } + store.builder.RebuildUids(store.Threads(), store.reverseThreadOrder) + } } } diff --git a/lib/threadbuilder.go b/lib/threadbuilder.go index 5a73397a..c2fee228 100644 --- a/lib/threadbuilder.go +++ b/lib/threadbuilder.go @@ -184,6 +184,9 @@ func (builder *ThreadBuilder) RebuildUids(threads []*types.Thread, inverse bool) var threaduids []uint32 _ = iterT.Value().(*types.Thread).Walk( func(t *types.Thread, level int, currentErr error) error { + if t.Deleted || t.Hidden { + return nil + } threaduids = append(threaduids, t.Uid) return nil }) |