aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Culverhouse <tim@timculverhouse.com>2022-08-16 16:23:41 -0500
committerRobin Jarry <robin@jarry.cc>2022-08-22 15:46:55 +0200
commitc98f70487417825ca592c928cbf0144ba88eef7e (patch)
tree8eee893e3155fc7a24224b47a99268fa6a83ebf9
parentaf72ca36072615f3afc79d7a3f28f82e381b618c (diff)
downloadaerc-c98f70487417825ca592c928cbf0144ba88eef7e.tar.gz
move: enable MoveMessages from msgstore
Enable the use of MoveMessages worker messages from the UI to the backend. Completes implemention of MoveMessages for all supported backends. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
-rw-r--r--lib/msgstore.go4
-rw-r--r--widgets/account.go90
2 files changed, 50 insertions, 44 deletions
diff --git a/lib/msgstore.go b/lib/msgstore.go
index 2832346c..2ce531c8 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 bc2dc360..60468767 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