aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/dirlist.go
diff options
context:
space:
mode:
authorReto Brunner <reto@labrat.space>2020-02-15 14:14:42 +0100
committerDrew DeVault <sir@cmpwn.com>2020-02-16 10:41:15 -0500
commitbd4df530095ee343778a59120a9e641c01010b0f (patch)
tree2995671ce6986d39b3389ce7ffad0b15e3a162c3 /widgets/dirlist.go
parent30c0a9fba471bcd023c8aeebb3901803bb35d31f (diff)
downloadaerc-bd4df530095ee343778a59120a9e641c01010b0f.tar.gz
Only fetch the directory contents when we are switching directories
Previously, sending a DirectoryInfo assumed that a directory change happened. However we don't want that if we only want to update the unread message count.
Diffstat (limited to 'widgets/dirlist.go')
-rw-r--r--widgets/dirlist.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/widgets/dirlist.go b/widgets/dirlist.go
index 9267a3cb..e8a93091 100644
--- a/widgets/dirlist.go
+++ b/widgets/dirlist.go
@@ -11,6 +11,7 @@ import (
"git.sr.ht/~sircmpwn/aerc/config"
"git.sr.ht/~sircmpwn/aerc/lib"
+ libsort "git.sr.ht/~sircmpwn/aerc/lib/sort"
"git.sr.ht/~sircmpwn/aerc/lib/ui"
"git.sr.ht/~sircmpwn/aerc/models"
"git.sr.ht/~sircmpwn/aerc/worker/types"
@@ -104,6 +105,10 @@ func (dirlist *DirectoryList) Select(name string) {
}
sort.Strings(dirlist.dirs)
dirlist.sortDirsByFoldersSortConfig()
+ // once opened, we need to enumerate the contents
+ dirlist.worker.PostAction(&types.FetchDirectoryContents{
+ SortCriteria: dirlist.getSortCriteria(),
+ }, nil)
}
dirlist.Invalidate()
})
@@ -378,3 +383,15 @@ func findString(slice []string, str string) int {
}
return -1
}
+
+func (dirlist *DirectoryList) getSortCriteria() []*types.SortCriterion {
+ if len(dirlist.UiConfig().Sort) == 0 {
+ return nil
+ }
+ criteria, err := libsort.GetSortCriteria(dirlist.UiConfig().Sort)
+ if err != nil {
+ dirlist.logger.Printf("getSortCriteria failed: %v", err)
+ return nil
+ }
+ return criteria
+}