aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/account.go
diff options
context:
space:
mode:
authorTim Culverhouse <tim@timculverhouse.com>2022-06-03 13:34:01 -0500
committerRobin Jarry <robin@jarry.cc>2022-06-07 16:19:31 +0200
commit2027223ab302f803952c486ec40f1e859638a273 (patch)
tree96adb78541114c402d92e5f3c2ae68b7dbf81375 /widgets/account.go
parent955f7683af104b98ec67ef259f0cbe4c8f2a52ed (diff)
downloadaerc-2027223ab302f803952c486ec40f1e859638a273.tar.gz
fix: clear dirlist on disconnect
A message of Done:Disconnect will trigger an update of the dirlist. An update of the dirlist will issue a ListDirectories message, which causes an imap: client not ready error by trying to use the imap connection - which is disconnected. By not issuing the update, we prevent using a disconnected client. This patch checks for connection state prior to updating the dirlist. A disconnected state will clear out the dirlist. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'widgets/account.go')
-rw-r--r--widgets/account.go2
1 files changed, 2 insertions, 0 deletions
diff --git a/widgets/account.go b/widgets/account.go
index 2d3b0d2a..93403709 100644
--- a/widgets/account.go
+++ b/widgets/account.go
@@ -246,6 +246,7 @@ func (acct *AccountView) onMessage(msg types.WorkerMessage) {
case *types.Connect, *types.Reconnect:
acct.SetStatus(statusline.ConnectionActivity("Listing mailboxes..."))
acct.logger.Println("Listing mailboxes...")
+ acct.dirlist.SetConnected(true)
acct.dirlist.UpdateList(func(dirs []string) {
var dir string
for _, _dir := range dirs {
@@ -266,6 +267,7 @@ func (acct *AccountView) onMessage(msg types.WorkerMessage) {
acct.newConn = true
})
case *types.Disconnect:
+ acct.dirlist.SetConnected(false)
acct.dirlist.UpdateList(nil)
acct.msglist.SetStore(nil)
acct.logger.Println("Disconnected.")