diff --git a/lib/msgstore.go b/lib/msgstore.go index 2832346..2ce531c 100644 --- a/lib/msgstore.go +++ b/lib/msgstore.go @@ -476,7 +476,7 @@ func (store *MessageStore) Move(uids []uint32, dest string, createDest bool, }, nil) // quiet doesn't return an error, don't want the done cb here } - store.worker.PostAction(&types.CopyMessages{ + store.worker.PostAction(&types.MoveMessages{ Destination: dest, Uids: uids, }, func(msg types.WorkerMessage) { @@ -485,7 +485,7 @@ func (store *MessageStore) Move(uids []uint32, dest string, createDest bool, store.revertDeleted(uids) cb(msg) case *types.Done: - store.Delete(uids, cb) + cb(msg) } }) } diff --git a/widgets/account.go b/widgets/account.go index bc2dc36..6046876 100644 --- a/widgets/account.go +++ b/widgets/account.go @@ -346,48 +346,9 @@ func (acct *AccountView) onMessage(msg types.WorkerMessage) { 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 - var accurate bool = true - for _, uid := range msg.Uids { - // Get the message from the originating store - msg, ok := acct.Store().Messages[uid] - if !ok { - continue - } - // If message that was not yet loaded is copied - if msg == nil { - accurate = false - break - } - seen := false - for _, flag := range msg.Flags { - if flag == models.SeenFlag { - seen = true - } - if flag == models.RecentFlag { - recent++ - } - } - if !seen { - unseen++ - } - } - if accurate { - 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 - } else { - destStore.DirInfo.Exists += len(msg.Uids) - // False to trigger recount of recent/unseen - destStore.DirInfo.AccurateCounts = false - } - } + acct.updateDirCounts(msg.Destination, msg.Uids) + case *types.MessagesMoved: + acct.updateDirCounts(msg.Destination, msg.Uids) case *types.LabelList: acct.labels = msg.Labels case *types.ConnError: @@ -403,6 +364,51 @@ func (acct *AccountView) onMessage(msg types.WorkerMessage) { acct.UpdateStatus() } +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 { + var recent, unseen int + var accurate bool = true + for _, uid := range uids { + // Get the message from the originating store + msg, ok := acct.Store().Messages[uid] + if !ok { + continue + } + // If message that was not yet loaded is copied + if msg == nil { + accurate = false + break + } + seen := false + for _, flag := range msg.Flags { + if flag == models.SeenFlag { + seen = true + } + if flag == models.RecentFlag { + recent++ + } + } + if !seen { + unseen++ + } + } + 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 + } else { + destStore.DirInfo.Exists += len(uids) + // False to trigger recount of recent/unseen + destStore.DirInfo.AccurateCounts = false + } + } +} + func (acct *AccountView) GetSortCriteria() []*types.SortCriterion { if len(acct.UiConfig().Sort) == 0 { return nil