summaryrefslogtreecommitdiff
path: root/widgets/account.go
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2021-11-01 21:38:26 +0100
committerRobin Jarry <robin@jarry.cc>2021-11-05 10:45:31 +0100
commite41ed82cf3dbb4a1152a562ab754a9dc4a6c57b3 (patch)
tree098cc67f60eb3e0d7c16ad82adb4c988aa08c61e /widgets/account.go
parent20752df89c3bef0aca23493bfe8a668b93db9947 (diff)
downloadaerc-e41ed82cf3dbb4a1152a562ab754a9dc4a6c57b3.zip
imap: add manual {dis,}connect support
Signed-off-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'widgets/account.go')
-rw-r--r--widgets/account.go59
1 files changed, 31 insertions, 28 deletions
diff --git a/widgets/account.go b/widgets/account.go
index 891278a..2f126a3 100644
--- a/widgets/account.go
+++ b/widgets/account.go
@@ -85,7 +85,7 @@ func NewAccountView(aerc *Aerc, conf *config.AercConfig, acct *config.AccountCon
go worker.Backend.Run()
worker.PostAction(&types.Configure{Config: acct}, nil)
- worker.PostAction(&types.Connect{}, view.connected)
+ worker.PostAction(&types.Connect{}, nil)
host.SetStatus("Connecting...")
return view, nil
@@ -105,6 +105,10 @@ func (acct *AccountView) Tick() bool {
}
}
+func (acct *AccountView) SetStatus(msg string) {
+ acct.host.SetStatus(msg)
+}
+
func (acct *AccountView) AccountConfig() *config.AccountConfig {
return acct.acct
}
@@ -147,33 +151,6 @@ func (acct *AccountView) Focus(focus bool) {
// TODO: Unfocus children I guess
}
-func (acct *AccountView) connected(msg types.WorkerMessage) {
- switch msg.(type) {
- case *types.Done:
- acct.host.SetStatus("Listing mailboxes...")
- acct.logger.Println("Listing mailboxes...")
- acct.dirlist.UpdateList(func(dirs []string) {
- var dir string
- for _, _dir := range dirs {
- if _dir == acct.acct.Default {
- dir = _dir
- break
- }
- }
- if dir == "" && len(dirs) > 0 {
- dir = dirs[0]
- }
- if dir != "" {
- acct.dirlist.Select(dir)
- }
-
- acct.msglist.SetInitDone()
- acct.logger.Println("Connected.")
- acct.host.SetStatus("Connected.")
- })
- }
-}
-
func (acct *AccountView) Directories() *DirectoryList {
return acct.dirlist
}
@@ -225,6 +202,32 @@ func (acct *AccountView) onMessage(msg types.WorkerMessage) {
switch msg := msg.(type) {
case *types.Done:
switch msg.InResponseTo().(type) {
+ case *types.Connect:
+ acct.host.SetStatus("Listing mailboxes...")
+ acct.logger.Println("Listing mailboxes...")
+ acct.dirlist.UpdateList(func(dirs []string) {
+ var dir string
+ for _, _dir := range dirs {
+ if _dir == acct.acct.Default {
+ dir = _dir
+ break
+ }
+ }
+ if dir == "" && len(dirs) > 0 {
+ dir = dirs[0]
+ }
+ if dir != "" {
+ acct.dirlist.Select(dir)
+ }
+ acct.msglist.SetInitDone()
+ acct.logger.Println("Connected.")
+ acct.host.SetStatus("Connected.")
+ })
+ case *types.Disconnect:
+ acct.dirlist.UpdateList(nil)
+ acct.msglist.SetStore(nil)
+ acct.logger.Println("Disconnected.")
+ acct.host.SetStatus("Disconnected.")
case *types.OpenDirectory:
if store, ok := acct.dirlist.SelectedMsgStore(); ok {
// If we've opened this dir before, we can re-render it from