diff options
Diffstat (limited to 'widgets')
-rw-r--r-- | widgets/account.go | 34 | ||||
-rw-r--r-- | widgets/dirlist.go | 12 |
2 files changed, 38 insertions, 8 deletions
diff --git a/widgets/account.go b/widgets/account.go index e913cb7..2d3b0d2 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: diff --git a/widgets/dirlist.go b/widgets/dirlist.go index 99ffe19..60bd7fa 100644 --- a/widgets/dirlist.go +++ b/widgets/dirlist.go @@ -244,16 +244,12 @@ func (dirlist *DirectoryList) getRUEString(name string) string { return "" } var totalRecent, totalUnseen, totalExists int - if msgStore.DirInfo.AccurateCounts { - totalRecent = msgStore.DirInfo.Recent - totalUnseen = msgStore.DirInfo.Unseen - totalExists = msgStore.DirInfo.Exists - } else { + if !msgStore.DirInfo.AccurateCounts { totalRecent, totalUnseen = countRUE(msgStore) - // use the total count from the dirinfo, else we only count already - // fetched messages - totalExists = msgStore.DirInfo.Exists + msgStore.DirInfo.Recent = totalRecent + msgStore.DirInfo.Unseen = totalUnseen } + totalExists = msgStore.DirInfo.Exists rueString := "" if totalRecent > 0 { rueString = fmt.Sprintf("%d/%d/%d", totalRecent, totalUnseen, totalExists) |