mirror of
https://git.sr.ht/~rjarry/aerc
synced 2026-03-02 18:23:33 +01:00
msgstore: do not trigger notification on initial load
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>
This commit is contained in:
committed by
Robin Jarry
parent
6512eb2e29
commit
8d4704775b
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user