diff options
author | Gregory Mullen <greg@cmdline.org> | 2019-06-27 10:33:12 -0700 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2019-06-29 14:24:19 -0400 |
commit | 546dfcd76dd228e0605359e9985f0b6a5672e8fa (patch) | |
tree | ac319094d0361c3ed41765c027cbaad2db5b05af /widgets | |
parent | 2a0961701c4cabecc53d134ed1782e5612e64580 (diff) | |
download | aerc-546dfcd76dd228e0605359e9985f0b6a5672e8fa.tar.gz |
Add new lib/dirstore to source completions from
Diffstat (limited to 'widgets')
-rw-r--r-- | widgets/dirlist.go | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/widgets/dirlist.go b/widgets/dirlist.go index 71cf79d8..944b72eb 100644 --- a/widgets/dirlist.go +++ b/widgets/dirlist.go @@ -7,6 +7,7 @@ import ( "github.com/gdamore/tcell" "git.sr.ht/~sircmpwn/aerc/config" + "git.sr.ht/~sircmpwn/aerc/lib" "git.sr.ht/~sircmpwn/aerc/lib/ui" "git.sr.ht/~sircmpwn/aerc/worker/types" ) @@ -15,6 +16,7 @@ type DirectoryList struct { ui.Invalidatable acctConf *config.AccountConfig uiConf *config.UIConfig + store *lib.DirStore dirs []string logger *log.Logger selecting string @@ -31,6 +33,7 @@ func NewDirectoryList(acctConf *config.AccountConfig, uiConf *config.UIConfig, uiConf: uiConf, logger: logger, spinner: NewSpinner(), + store: lib.NewDirStore(), worker: worker, } dirlist.spinner.OnInvalidate(func(_ ui.Drawable) { @@ -54,7 +57,7 @@ func (dirlist *DirectoryList) UpdateList(done func(dirs []string)) { dirs = append(dirs, msg.Name) case *types.Done: sort.Strings(dirs) - dirlist.dirs = dirs + dirlist.store.Update(dirs) dirlist.spinner.Stop() dirlist.Invalidate() if done != nil { @@ -107,14 +110,14 @@ func (dirlist *DirectoryList) Draw(ctx *ui.Context) { return } - if len(dirlist.dirs) == 0 { + if len(dirlist.store.List()) == 0 { style := tcell.StyleDefault ctx.Printf(0, 0, style, dirlist.uiConf.EmptyDirlist) return } row := 0 - for _, name := range dirlist.dirs { + for _, name := range dirlist.store.List() { if row >= ctx.Height() { break } @@ -180,7 +183,7 @@ func (dirlist *DirectoryList) filterDirsByFoldersConfig() { return } var filtered []string - for _, folder := range dirlist.dirs { + for _, folder := range dirlist.store.List() { for _, cfgfolder := range dirlist.acctConf.Folders { if folder == cfgfolder { filtered = append(filtered, folder) |