Remove dirs field and references to it
This fixes prev/next-folder that broke after
546dfcd76d
This commit is contained in:
parent
5b4e592371
commit
0e55637aac
1 changed files with 11 additions and 10 deletions
|
@ -17,7 +17,6 @@ type DirectoryList struct {
|
||||||
acctConf *config.AccountConfig
|
acctConf *config.AccountConfig
|
||||||
uiConf *config.UIConfig
|
uiConf *config.UIConfig
|
||||||
store *lib.DirStore
|
store *lib.DirStore
|
||||||
dirs []string
|
|
||||||
logger *log.Logger
|
logger *log.Logger
|
||||||
selecting string
|
selecting string
|
||||||
selected string
|
selected string
|
||||||
|
@ -44,7 +43,7 @@ func NewDirectoryList(acctConf *config.AccountConfig, uiConf *config.UIConfig,
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dirlist *DirectoryList) List() []string {
|
func (dirlist *DirectoryList) List() []string {
|
||||||
return dirlist.dirs
|
return dirlist.store.List()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dirlist *DirectoryList) UpdateList(done func(dirs []string)) {
|
func (dirlist *DirectoryList) UpdateList(done func(dirs []string)) {
|
||||||
|
@ -78,16 +77,18 @@ func (dirlist *DirectoryList) Select(name string) {
|
||||||
dirlist.selected = dirlist.selecting
|
dirlist.selected = dirlist.selecting
|
||||||
dirlist.filterDirsByFoldersConfig()
|
dirlist.filterDirsByFoldersConfig()
|
||||||
hasSelected := false
|
hasSelected := false
|
||||||
for _, d := range dirlist.dirs {
|
dirs := dirlist.store.List()
|
||||||
|
for _, d := range dirs {
|
||||||
if d == dirlist.selected {
|
if d == dirlist.selected {
|
||||||
hasSelected = true
|
hasSelected = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !hasSelected && dirlist.selected != "" {
|
if !hasSelected && dirlist.selected != "" {
|
||||||
dirlist.dirs = append(dirlist.dirs, dirlist.selected)
|
dirs = append(dirs, dirlist.selected)
|
||||||
}
|
}
|
||||||
sort.Strings(dirlist.dirs)
|
sort.Strings(dirs)
|
||||||
|
dirlist.store.Update(dirs)
|
||||||
}
|
}
|
||||||
dirlist.Invalidate()
|
dirlist.Invalidate()
|
||||||
})
|
})
|
||||||
|
@ -139,10 +140,10 @@ func (dirlist *DirectoryList) Draw(ctx *ui.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dirlist *DirectoryList) nextPrev(delta int) {
|
func (dirlist *DirectoryList) nextPrev(delta int) {
|
||||||
for i, dir := range dirlist.dirs {
|
for i, dir := range dirlist.store.List() {
|
||||||
if dir == dirlist.selected {
|
if dir == dirlist.selected {
|
||||||
var j int
|
var j int
|
||||||
ndirs := len(dirlist.dirs)
|
ndirs := len(dirlist.store.List())
|
||||||
for j = i + delta; j != i; j += delta {
|
for j = i + delta; j != i; j += delta {
|
||||||
if j < 0 {
|
if j < 0 {
|
||||||
j = ndirs - 1
|
j = ndirs - 1
|
||||||
|
@ -150,7 +151,7 @@ func (dirlist *DirectoryList) nextPrev(delta int) {
|
||||||
if j >= ndirs {
|
if j >= ndirs {
|
||||||
j = 0
|
j = 0
|
||||||
}
|
}
|
||||||
name := dirlist.dirs[j]
|
name := dirlist.store.List()[j]
|
||||||
if len(dirlist.acctConf.Folders) > 1 && name != dirlist.selected {
|
if len(dirlist.acctConf.Folders) > 1 && name != dirlist.selected {
|
||||||
idx := sort.SearchStrings(dirlist.acctConf.Folders, name)
|
idx := sort.SearchStrings(dirlist.acctConf.Folders, name)
|
||||||
if idx == len(dirlist.acctConf.Folders) ||
|
if idx == len(dirlist.acctConf.Folders) ||
|
||||||
|
@ -161,7 +162,7 @@ func (dirlist *DirectoryList) nextPrev(delta int) {
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
dirlist.Select(dirlist.dirs[j])
|
dirlist.Select(dirlist.store.List()[j])
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -191,5 +192,5 @@ func (dirlist *DirectoryList) filterDirsByFoldersConfig() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dirlist.dirs = filtered
|
dirlist.store.Update(filtered)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue