about summary refs log tree commit diff stats
path: root/widgets/dirlist.go
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2019-07-02 19:43:41 -0400
committerDrew DeVault <sir@cmpwn.com>2019-07-02 19:43:41 -0400
commit491e36017868b266e507f5b26d57aa19cb9bf280 (patch)
treea509f953ecf8add494c123c7a666dc20a2952135 /widgets/dirlist.go
parent0e55637aac92e748267559b7aa91a188a17c386f (diff)
downloadaerc-491e36017868b266e507f5b26d57aa19cb9bf280.tar.gz
Revert "Remove dirs field and references to it"
This reverts commit 0e55637aac92e748267559b7aa91a188a17c386f.
Diffstat (limited to 'widgets/dirlist.go')
-rw-r--r--widgets/dirlist.go21
1 files changed, 10 insertions, 11 deletions
diff --git a/widgets/dirlist.go b/widgets/dirlist.go
index 65fed9b..944b72e 100644
--- a/widgets/dirlist.go
+++ b/widgets/dirlist.go
@@ -17,6 +17,7 @@ type DirectoryList struct {
 	acctConf  *config.AccountConfig
 	uiConf    *config.UIConfig
 	store     *lib.DirStore
+	dirs      []string
 	logger    *log.Logger
 	selecting string
 	selected  string
@@ -43,7 +44,7 @@ func NewDirectoryList(acctConf *config.AccountConfig, uiConf *config.UIConfig,
 }
 
 func (dirlist *DirectoryList) List() []string {
-	return dirlist.store.List()
+	return dirlist.dirs
 }
 
 func (dirlist *DirectoryList) UpdateList(done func(dirs []string)) {
@@ -77,18 +78,16 @@ func (dirlist *DirectoryList) Select(name string) {
 				dirlist.selected = dirlist.selecting
 				dirlist.filterDirsByFoldersConfig()
 				hasSelected := false
-				dirs := dirlist.store.List()
-				for _, d := range dirs {
+				for _, d := range dirlist.dirs {
 					if d == dirlist.selected {
 						hasSelected = true
 						break
 					}
 				}
 				if !hasSelected && dirlist.selected != "" {
-					dirs = append(dirs, dirlist.selected)
+					dirlist.dirs = append(dirlist.dirs, dirlist.selected)
 				}
-				sort.Strings(dirs)
-				dirlist.store.Update(dirs)
+				sort.Strings(dirlist.dirs)
 			}
 			dirlist.Invalidate()
 		})
@@ -140,10 +139,10 @@ func (dirlist *DirectoryList) Draw(ctx *ui.Context) {
 }
 
 func (dirlist *DirectoryList) nextPrev(delta int) {
-	for i, dir := range dirlist.store.List() {
+	for i, dir := range dirlist.dirs {
 		if dir == dirlist.selected {
 			var j int
-			ndirs := len(dirlist.store.List())
+			ndirs := len(dirlist.dirs)
 			for j = i + delta; j != i; j += delta {
 				if j < 0 {
 					j = ndirs - 1
@@ -151,7 +150,7 @@ func (dirlist *DirectoryList) nextPrev(delta int) {
 				if j >= ndirs {
 					j = 0
 				}
-				name := dirlist.store.List()[j]
+				name := dirlist.dirs[j]
 				if len(dirlist.acctConf.Folders) > 1 && name != dirlist.selected {
 					idx := sort.SearchStrings(dirlist.acctConf.Folders, name)
 					if idx == len(dirlist.acctConf.Folders) ||
@@ -162,7 +161,7 @@ func (dirlist *DirectoryList) nextPrev(delta int) {
 				}
 				break
 			}
-			dirlist.Select(dirlist.store.List()[j])
+			dirlist.Select(dirlist.dirs[j])
 			break
 		}
 	}
@@ -192,5 +191,5 @@ func (dirlist *DirectoryList) filterDirsByFoldersConfig() {
 			}
 		}
 	}
-	dirlist.store.Update(filtered)
+	dirlist.dirs = filtered
 }