imap: reconnect when connection closed v1 PROPOSED

Anjandev Momi: 1
 imap: reconnect when connection closed

 1 files changed, 6 insertions(+), 0 deletions(-)
I agree that this is not the appropriate way of handling this issue. We
need to:

1. Make the worker bubble up a disconnection notification, with an error
2. Update the UI to explain that we're offline, and disable write
3. Have the UI initiate a worker reconnection with an exponential

And we need a :disconnect and :reconnect option for the user to do this
at will.
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~sircmpwn/aerc/patches/9455/mbox | git am -3
Learn more about email & git

[PATCH] imap: reconnect when connection closed Export this patch

 widgets/account.go | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/widgets/account.go b/widgets/account.go
index 404a9ea..5bbb29b 100644
--- a/widgets/account.go
+++ b/widgets/account.go
@@ -268,6 +268,12 @@ func (acct *AccountView) onMessage(msg types.WorkerMessage) {
		acct.logger.Printf("%v", msg.Error)
		acct.host.SetStatus(fmt.Sprintf("%v", msg.Error)).
			Color(tcell.ColorDefault, tcell.ColorRed)
		if (msg.Error.Error() == "imap: connection closed") {
			acct.worker.PostAction(&types.Connect{}, nil)
			acct.logger.Printf("imap: reconnected")
			acct.host.SetStatus(fmt.Sprintf("imap: reconnected")).
				Color(tcell.ColorDefault, tcell.ColorWhite)

Thanks for your patch.
However, this is no the right approach in my opinion.

The error you are catching is specific to the imap worker and needs to be addressed
in the worker, located under /worker/imap.

Also I think we should reconnect and then retry to handle the message (the task)
we just tried to process, up to a certain retry limit of course.