aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/account.go
diff options
context:
space:
mode:
authorTim Culverhouse <tim@timculverhouse.com>2023-04-16 09:53:44 -0500
committerRobin Jarry <robin@jarry.cc>2023-04-22 22:40:12 +0200
commit5b0a98b8c936532fa5444b1cabf53d7c929d19c1 (patch)
treeb04415f6120d944cd74c45464a771d064cdd4305 /widgets/account.go
parentf13fbe7a27756c63d85f40c15320664d634f59e2 (diff)
downloadaerc-5b0a98b8c936532fa5444b1cabf53d7c929d19c1.tar.gz
directory: use directory to store rue counts
Store the Directory RUE counts on the Directory data model. Use DirectoryInfo messages to update the Directory model. Access Directories via the dirlist instead of via the msgstore. Remove unused fields on DirectoryInfo, all backends now give accurate counts. Move refetch logic into dirlist 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.go28
1 files changed, 10 insertions, 18 deletions
diff --git a/widgets/account.go b/widgets/account.go
index 6449aeba..983c2382 100644
--- a/widgets/account.go
+++ b/widgets/account.go
@@ -310,9 +310,7 @@ func (acct *AccountView) onMessage(msg types.WorkerMessage) {
store.SetMarker(marker.New(store))
acct.dirlist.SetMsgStore(msg.Dir, store)
case *types.DirectoryInfo:
- if store, ok := acct.dirlist.MsgStore(msg.Info.Name); ok {
- store.Update(msg)
- }
+ acct.dirlist.Update(msg)
case *types.DirectoryContents:
if store, ok := acct.dirlist.SelectedMsgStore(); ok {
if acct.msglist.Store() == nil {
@@ -344,10 +342,10 @@ func (acct *AccountView) onMessage(msg types.WorkerMessage) {
store.Update(msg)
}
case *types.MessagesDeleted:
+ if dir := acct.dirlist.SelectedDirectory(); dir != nil {
+ dir.Exists -= len(msg.Uids)
+ }
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:
@@ -371,8 +369,8 @@ func (acct *AccountView) onMessage(msg types.WorkerMessage) {
}
func (acct *AccountView) updateDirCounts(destination string, uids []uint32) {
- // Only update the destination destStore if it is initialized
- if destStore, ok := acct.dirlist.MsgStore(destination); ok {
+ // Only update the destination destDir if it is initialized
+ if destDir := acct.dirlist.Directory(destination); destDir != nil {
var recent, unseen int
var accurate bool = true
for _, uid := range uids {
@@ -395,17 +393,11 @@ func (acct *AccountView) updateDirCounts(destination string, uids []uint32) {
}
}
if accurate {
- destStore.DirInfo.Recent += recent
- destStore.DirInfo.Unseen += unseen
- destStore.DirInfo.Exists += len(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
+ destDir.Recent += recent
+ destDir.Unseen += unseen
+ destDir.Exists += len(uids)
} else {
- destStore.DirInfo.Exists += len(uids)
- // False to trigger recount of recent/unseen
- destStore.DirInfo.AccurateCounts = false
+ destDir.Exists += len(uids)
}
}
}