From 9f4da4de0c9b3a330a8c7032e285117cfa5448dc Mon Sep 17 00:00:00 2001 From: Koni Marti Date: Sun, 20 Mar 2022 09:47:52 +0100 Subject: msglist: update message counter upon filter change Update message counter in msglist when the filter is changed (either set or cleared in the msgstore). When we apply a filter, we change the number of uids in the message store. This can unintentionally trigger the storeUpdate() function of the msglist which checks the number of uids for new messages and advances the pointer by the difference in the number of messages. This can be avoided when we update the message counter upon changing the filter. Fixes: https://todo.sr.ht/~rjarry/aerc/23 Signed-off-by: Koni Marti Acked-by: Robin Jarry --- widgets/msglist.go | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'widgets') diff --git a/widgets/msglist.go b/widgets/msglist.go index f4cea70..5eee7ed 100644 --- a/widgets/msglist.go +++ b/widgets/msglist.go @@ -367,6 +367,12 @@ func (ml *MessageList) SetStore(store *lib.MessageStore) { ml.spinner.Stop() ml.nmsgs = len(store.Uids()) store.OnUpdate(ml.storeUpdate) + store.OnFilterChange(func(store *lib.MessageStore) { + if ml.Store() != store { + return + } + ml.nmsgs = len(store.Uids()) + }) } else { ml.spinner.Start() } -- cgit v1.2.3