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.
Signed-off-by: Remko Tronçon <remko@el-tramo.be>
---
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 <remko@el-tramo.be> wrote:
> 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.
>
> Signed-off-by: Remko Tronçon <remko@el-tramo.be>
> ---
Acked-by: Robin Jarry <robin@jarry.cc>
Applied, thanks.
To git@git.sr.ht:~rjarry/aerc
6512eb2e29b8..8d4704775b1e master -> master