diff options
author | Tim Culverhouse <tim@timculverhouse.com> | 2022-06-01 19:24:53 -0500 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2022-06-07 16:19:23 +0200 |
commit | 8b6f9719a84fa0ee31d84b9e864495af4f166d92 (patch) | |
tree | 8c5bc108673cce4a33e124c20855e633acabd667 /widgets/account.go | |
parent | 4985d1bab8996a995bd93abe120835320e3c7d82 (diff) | |
download | aerc-8b6f9719a84fa0ee31d84b9e864495af4f166d92.tar.gz |
dirlist: update RUE counts for imap/maildir on move|copy|delete|archive
When moving/copying/deleting/archiving a message in imap, the RUE counts
displayed in the dirlist would not update properly. Maildir has (had) an
implementation that recounts the entire directory and updates the
DirectoryInfo after one of these actions.
This patch implements a more efficient method of updating, and also
enables it to apply to IMAP without any additional requests. Upon
completion of the action, the counts are manually updated with the count
of messages in the action and recent and/or unseen states of those
messages. This is more efficient for maildir, because we aren't counting
everything in the store. For IMAP, we get the updates for free because
we are only performing the update after confirmation from the server
that the action has happened.
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'widgets/account.go')
-rw-r--r-- | widgets/account.go | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/widgets/account.go b/widgets/account.go index e913cb7e..2d3b0d2a 100644 --- a/widgets/account.go +++ b/widgets/account.go @@ -331,8 +331,42 @@ func (acct *AccountView) onMessage(msg types.WorkerMessage) { } case *types.MessagesDeleted: if store, ok := acct.dirlist.SelectedMsgStore(); ok { + store.DirInfo.Exists -= len(msg.Uids) + // False to trigger recount of recent/unseen + store.DirInfo.AccurateCounts = false store.Update(msg) } + case *types.MessagesCopied: + // Only update the destination destStore if it is initialized + if destStore, ok := acct.dirlist.MsgStore(msg.Destination); ok { + var recent, unseen int + for _, uid := range msg.Uids { + // Get the message from the originating store + msg, ok := acct.Store().Messages[uid] + if !ok { + continue + } + seen := false + for _, flag := range msg.Flags { + if flag == models.SeenFlag { + seen = true + } + if flag == models.RecentFlag { + recent = recent + 1 + } + } + if !seen { + unseen = unseen + 1 + } + } + destStore.DirInfo.Recent += recent + destStore.DirInfo.Unseen += unseen + destStore.DirInfo.Exists += len(msg.Uids) + // True. For imap, we don't have the message in the store until we + // Select so we need to rely on the math we just did for accurate + // counts + destStore.DirInfo.AccurateCounts = true + } case *types.LabelList: acct.labels = msg.Labels case *types.ConnError: |