delete: move tab replace logic into Done callback
Move tab replacement logic for next-message-on-delete into the callback. This also moves the Invalidate() call into the callback, and should make imap deletion UI work more reliably - there is a race condition between the worker and the UI in displaying deleted messages. This should resolve the race condition, and also only remove the MsgView tab if the message is actually deleted. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
This commit is contained in:
parent
0f86666f52
commit
80f8bab6cf
|
@ -42,21 +42,12 @@ func (Delete) Execute(aerc *widgets.Aerc, args []string) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
//caution, can be nil
|
||||||
|
next := findNextNonDeleted(uids, store)
|
||||||
store.Delete(uids, func(msg types.WorkerMessage) {
|
store.Delete(uids, func(msg types.WorkerMessage) {
|
||||||
switch msg := msg.(type) {
|
switch msg := msg.(type) {
|
||||||
case *types.Done:
|
case *types.Done:
|
||||||
aerc.PushStatus("Messages deleted.", 10*time.Second)
|
aerc.PushStatus("Messages deleted.", 10*time.Second)
|
||||||
case *types.Error:
|
|
||||||
aerc.PushError(msg.Error.Error())
|
|
||||||
case *types.Unsupported:
|
|
||||||
// notmuch doesn't support it, we want the user to know
|
|
||||||
aerc.PushError(" error, unsupported for this worker")
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
//caution, can be nil
|
|
||||||
next := findNextNonDeleted(uids, store)
|
|
||||||
|
|
||||||
mv, isMsgView := h.msgProvider.(*widgets.MessageViewer)
|
mv, isMsgView := h.msgProvider.(*widgets.MessageViewer)
|
||||||
if isMsgView {
|
if isMsgView {
|
||||||
if !aerc.Config().Ui.NextMessageOnDelete {
|
if !aerc.Config().Ui.NextMessageOnDelete {
|
||||||
|
@ -66,7 +57,7 @@ func (Delete) Execute(aerc *widgets.Aerc, args []string) error {
|
||||||
if next == nil {
|
if next == nil {
|
||||||
aerc.RemoveTab(h.msgProvider)
|
aerc.RemoveTab(h.msgProvider)
|
||||||
acct.Messages().Invalidate()
|
acct.Messages().Invalidate()
|
||||||
return nil
|
return
|
||||||
}
|
}
|
||||||
lib.NewMessageStoreView(next, store, aerc.Crypto, aerc.DecryptKeys,
|
lib.NewMessageStoreView(next, store, aerc.Crypto, aerc.DecryptKeys,
|
||||||
func(view lib.MessageView, err error) {
|
func(view lib.MessageView, err error) {
|
||||||
|
@ -80,6 +71,13 @@ func (Delete) Execute(aerc *widgets.Aerc, args []string) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
acct.Messages().Invalidate()
|
acct.Messages().Invalidate()
|
||||||
|
case *types.Error:
|
||||||
|
aerc.PushError(msg.Error.Error())
|
||||||
|
case *types.Unsupported:
|
||||||
|
// notmuch doesn't support it, we want the user to know
|
||||||
|
aerc.PushError(" error, unsupported for this worker")
|
||||||
|
}
|
||||||
|
})
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue