~rjarry/aerc

6057d156e6abd0b4c309e00c05021213565a2775 — Tim Culverhouse 11 days ago 602a577
delete: revert deleted messages if Delete is unsupported

Delete operations are not supported by the notmuch backend. Revert
deleted messages when the operation is not supported, and reselect the
original selection.

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Tested-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2 files changed, 6 insertions(+), 0 deletions(-)

M commands/msg/delete.go
M lib/msgstore.go
M commands/msg/delete.go => commands/msg/delete.go +3 -0
@@ 42,6 42,7 @@ func (Delete) Execute(aerc *widgets.Aerc, args []string) error {
	if err != nil {
		return err
	}
	sel := store.Selected()
	// caution, can be nil
	next := findNextNonDeleted(uids, store)
	store.ClearVisualMark()


@@ 80,9 81,11 @@ func (Delete) Execute(aerc *widgets.Aerc, args []string) error {
			}
		case *types.Error:
			store.Remark()
			store.Select(sel.Uid)
			aerc.PushError(msg.Error.Error())
		case *types.Unsupported:
			store.Remark()
			store.Select(sel.Uid)
			// notmuch doesn't support it, we want the user to know
			aerc.PushError(" error, unsupported for this worker")
		}

M lib/msgstore.go => lib/msgstore.go +3 -0
@@ 440,6 440,9 @@ func (store *MessageStore) Delete(uids []uint32,
			if _, ok := msg.(*types.Error); ok {
				store.revertDeleted(uids)
			}
			if _, ok := msg.(*types.Unsupported); ok {
				store.revertDeleted(uids)
			}
			cb(msg)
		})
}