From cf664620005cf65d060e689fbb27b939dd3192a7 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Sun, 13 Jan 2019 15:32:52 -0500 Subject: Simplify approach to directory list This doesn't really need to be abstract tbh --- widgets/account.go | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'widgets/account.go') diff --git a/widgets/account.go b/widgets/account.go index d368d42..d99a21f 100644 --- a/widgets/account.go +++ b/widgets/account.go @@ -122,13 +122,25 @@ func (acct *AccountView) Event(event tcell.Event) bool { func (acct *AccountView) connected(msg types.WorkerMessage) { switch msg := msg.(type) { case *types.Done: - acct.statusline.Set("Connected.") - acct.logger.Println("Connected.") - acct.dirlist.UpdateList() + acct.statusline.Set("Listing mailboxes...") + acct.logger.Println("Listing mailboxes...") + acct.dirlist.UpdateList(func(dirs []string) { + var dir string + for _, _dir := range dirs { + if _dir == "INBOX" { + dir = _dir + break + } + } + if dir == "" { + dir = dirs[0] + } + acct.dirlist.Select(dir) + acct.logger.Println("Connected.") + acct.statusline.Set("Connected.") + }) case *types.CertificateApprovalRequest: // TODO: Ask the user - acct.logger.Println("Approved unknown certificate.") - acct.statusline.Push("Approved unknown certificate.", 5*time.Second) acct.worker.PostAction(&types.ApproveCertificate{ Message: types.RespondTo(msg), Approved: true, -- cgit v1.2.3