There currently is no difference between updating the store of a
directory that was already loaded, and a directory that has not yet been
initialized. When a directory is opened, and the initial update request
is processed, all messages are therefore treated as new, and the
directory change notification (i.e. bell) is triggered.
To prevent triggering this update, track whether the directory was
already initialized, and if not, don't send out any change
notifications.
---
lib/msgstore.go | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/lib/msgstore.go b/lib/msgstore.go
index 1250a9c0..f64590e0 100644
--- a/lib/msgstore.go
+++ b/lib/msgstore.go
@@ -56,6 +56,8 @@ type MessageStore struct {
buildThreads bool
builder *ThreadBuilder
+ directoryContentsLoaded bool
+
// Map of uids we've asked the worker to fetch
onUpdate func(store *MessageStore) // TODO: multiple onUpdate handlers
onFilterChange func(store *MessageStore)
@@ -256,6 +258,7 @@ func (store *MessageStore) Update(msg types.WorkerMessage) {
update := false
updateThreads := false
directoryChange := false
+ directoryContentsWasLoaded := store.directoryContentsLoaded
start := store.scrollOffset
end := store.scrollOffset + store.scrollLen
@@ -281,6 +284,7 @@ func (store *MessageStore) Update(msg types.WorkerMessage) {
if store.threadedView {
store.runThreadBuilderNow()
}
+ store.directoryContentsLoaded = true
case *types.DirectoryThreaded:
if store.builder == nil {
store.builder = NewThreadBuilder(store.iterFactory,
@@ -392,13 +396,13 @@ func (store *MessageStore) Update(msg types.WorkerMessage) {
store.update(updateThreads)
}
- if directoryChange && store.triggerDirectoryChange != nil {
+ if directoryContentsWasLoaded && directoryChange && store.triggerDirectoryChange != nil {
store.triggerDirectoryChange()
}
if len(newUids) > 0 {
store.FetchHeaders(newUids, nil)
- if store.triggerDirectoryChange != nil {
+ if directoryContentsWasLoaded && store.triggerDirectoryChange != nil {
store.triggerDirectoryChange()
}
}
--
2.39.0
Remko Tronçon, Dec 19, 2024 at 14:24:
> There currently is no difference between updating the store of a
> directory that was already loaded, and a directory that has not yet been
> initialized. When a directory is opened, and the initial update request
> is processed, all messages are therefore treated as new, and the
> directory change notification (i.e. bell) is triggered.
>
> To prevent triggering this update, track whether the directory was
> already initialized, and if not, don't send out any change
> notifications.
> ---
Hi Remko,
Could you re-send your patch after reading through CONTRIBUTING.md?
https://git.sr.ht/~rjarry/aerc/tree/master/item/CONTRIBUTING.md?view-source#L92-111
It misses a subject-prefix in order to be picked up by the automatic CI.
Also, if you can, I strongly advise you to run `gmake validate` before
sending the patch, it will help debunking obvious issues.
Thanks!