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>
This commit is contained in:
parent
af72ca3607
commit
c98f704874
2 changed files with 50 additions and 44 deletions
|
@ -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)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -346,11 +346,30 @@ func (acct *AccountView) onMessage(msg types.WorkerMessage) {
|
|||
store.Update(msg)
|
||||
}
|
||||
case *types.MessagesCopied:
|
||||
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:
|
||||
logging.Errorf("%s connection error: %v", acct.acct.Name, msg.Error)
|
||||
acct.SetStatus(statusline.SetConnected(false))
|
||||
acct.PushError(msg.Error)
|
||||
acct.msglist.SetStore(nil)
|
||||
acct.worker.PostAction(&types.Reconnect{}, nil)
|
||||
case *types.Error:
|
||||
logging.Errorf("%s unexpected error: %v", acct.acct.Name, msg.Error)
|
||||
acct.PushError(msg.Error)
|
||||
}
|
||||
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(msg.Destination); ok {
|
||||
if destStore, ok := acct.dirlist.MsgStore(destination); ok {
|
||||
var recent, unseen int
|
||||
var accurate bool = true
|
||||
for _, uid := range msg.Uids {
|
||||
for _, uid := range uids {
|
||||
// Get the message from the originating store
|
||||
msg, ok := acct.Store().Messages[uid]
|
||||
if !ok {
|
||||
|
@ -377,30 +396,17 @@ func (acct *AccountView) onMessage(msg types.WorkerMessage) {
|
|||
if accurate {
|
||||
destStore.DirInfo.Recent += recent
|
||||
destStore.DirInfo.Unseen += unseen
|
||||
destStore.DirInfo.Exists += len(msg.Uids)
|
||||
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(msg.Uids)
|
||||
destStore.DirInfo.Exists += len(uids)
|
||||
// False to trigger recount of recent/unseen
|
||||
destStore.DirInfo.AccurateCounts = false
|
||||
}
|
||||
}
|
||||
case *types.LabelList:
|
||||
acct.labels = msg.Labels
|
||||
case *types.ConnError:
|
||||
logging.Errorf("%s connection error: %v", acct.acct.Name, msg.Error)
|
||||
acct.SetStatus(statusline.SetConnected(false))
|
||||
acct.PushError(msg.Error)
|
||||
acct.msglist.SetStore(nil)
|
||||
acct.worker.PostAction(&types.Reconnect{}, nil)
|
||||
case *types.Error:
|
||||
logging.Errorf("%s unexpected error: %v", acct.acct.Name, msg.Error)
|
||||
acct.PushError(msg.Error)
|
||||
}
|
||||
acct.UpdateStatus()
|
||||
}
|
||||
|
||||
func (acct *AccountView) GetSortCriteria() []*types.SortCriterion {
|
||||
|
|
Loading…
Reference in a new issue