diff options
author | Drew DeVault <sir@cmpwn.com> | 2019-03-10 23:45:00 -0400 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2019-03-10 23:45:00 -0400 |
commit | b3896476a0e6978c0d7f6fedfb64588934a78f1e (patch) | |
tree | 735e92c3ecb2955ab53cb3f77f0c676fcd64f1a0 /widgets/account.go | |
parent | 289e3b09ea20e911071e5a0f274445429502e934 (diff) | |
download | aerc-b3896476a0e6978c0d7f6fedfb64588934a78f1e.tar.gz |
Fetch valid UIDs from server after opening dir
Diffstat (limited to 'widgets/account.go')
-rw-r--r-- | widgets/account.go | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/widgets/account.go b/widgets/account.go index c5545ef..3085d27 100644 --- a/widgets/account.go +++ b/widgets/account.go @@ -21,6 +21,7 @@ type AccountView struct { interactive ui.Interactive onInvalidate func(d ui.Drawable) runCmd func(cmd string) error + msgStores map[string]*MessageStore statusline *StatusLine statusbar *ui.Stack worker *types.Worker @@ -64,9 +65,10 @@ func NewAccountView(conf *config.AccountConfig, dirlist: dirlist, grid: grid, logger: logger, + msgStores: make(map[string]*MessageStore), runCmd: runCmd, - statusline: statusline, statusbar: statusbar, + statusline: statusline, worker: worker, } @@ -157,10 +159,6 @@ func (acct *AccountView) connected(msg types.WorkerMessage) { Message: types.RespondTo(msg), Approved: true, }, acct.connected) - case *types.Error: - acct.logger.Printf("%v", msg.Error) - acct.statusline.Set(fmt.Sprintf("%v", msg.Error)). - Color(tcell.ColorRed, tcell.ColorDefault) } } @@ -169,5 +167,30 @@ func (acct *AccountView) Directories() *DirectoryList { } func (acct *AccountView) onMessage(msg types.WorkerMessage) { - // TODO + switch msg := msg.(type) { + case *types.Done: + switch msg.InResponseTo().(type) { + case *types.OpenDirectory: + acct.worker.PostAction(&types.FetchDirectoryContents{}, + func(msg types.WorkerMessage) { + // TODO: Do we care + }) + } + case *types.DirectoryInfo: + if store, ok := acct.msgStores[msg.Name]; ok { + store.Update(msg) + } else { + acct.msgStores[msg.Name] = NewMessageStore(msg) + } + case *types.DirectoryContents: + store := acct.msgStores[acct.dirlist.selected] + store.Update(msg) + case *types.MessageInfo: + store := acct.msgStores[acct.dirlist.selected] + store.Update(msg) + case *types.Error: + acct.logger.Printf("%v", msg.Error) + acct.statusline.Set(fmt.Sprintf("%v", msg.Error)). + Color(tcell.ColorRed, tcell.ColorDefault) + } } |