aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/dirlist.go
diff options
context:
space:
mode:
authorTim Culverhouse <tim@timculverhouse.com>2022-05-30 07:34:18 -0500
committerRobin Jarry <robin@jarry.cc>2022-05-31 14:32:51 +0200
commit2551dd1bfa2c68a6ba8644a0c45b24fce8874674 (patch)
treeed752720e1a08708505fd9574b49629d5df84997 /widgets/dirlist.go
parent30d57889741cfa8284eec9b32b29144fe01002a2 (diff)
downloadaerc-2551dd1bfa2c68a6ba8644a0c45b24fce8874674.tar.gz
feat: add background mail polling option for all workers
Check for new mail (recent, unseen, exists counts) with an external command, or for imap with the STATUS command, at start or on reconnection and every X time duration IMAP: The selected folder is skipped, per specification. Additional config options are included for including/excluding folders explicitly. Maildir/Notmuch: An external command will be run in the background to check for new mail. An optional timeout can be used with maildir/notmuch. Default is 10s New account options: check-mail check-mail-cmd (maildir/notmuch only) check-mail-timeout (maildir/notmuch only), default 10s check-mail-include (IMAP only) check-mail-exclude (IMAP only) If unset, or set less than or equal to 0, check-mail will be ignored Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Tested-by: Moritz Poldrack <moritz@poldrack.dev> Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'widgets/dirlist.go')
-rw-r--r--widgets/dirlist.go55
1 files changed, 30 insertions, 25 deletions
diff --git a/widgets/dirlist.go b/widgets/dirlist.go
index 412ed06c..ca0f6c19 100644
--- a/widgets/dirlist.go
+++ b/widgets/dirlist.go
@@ -40,6 +40,8 @@ type DirectoryLister interface {
SelectedMsgStore() (*lib.MessageStore, bool)
MsgStore(string) (*lib.MessageStore, bool)
SetMsgStore(string, *lib.MessageStore)
+
+ FilterDirs([]string, []string, bool) []string
}
type DirectoryList struct {
@@ -441,38 +443,41 @@ func (dirlist *DirectoryList) sortDirsByFoldersSortConfig() {
// dirstore, based on AccountConfig.Folders (inclusion) and
// AccountConfig.FoldersExclude (exclusion), in that order.
func (dirlist *DirectoryList) filterDirsByFoldersConfig() {
- filterDirs := func(orig, filters []string, exclude bool) []string {
- if len(filters) == 0 {
- return orig
- }
- var dest []string
- for _, folder := range orig {
- // When excluding, include things by default, and vice-versa
- include := exclude
- for _, f := range filters {
- if folderMatches(folder, f) {
- // If matched an exclusion, don't include
- // If matched an inclusion, do include
- include = !exclude
- break
- }
- }
- if include {
- dest = append(dest, folder)
- }
- }
- return dest
- }
-
dirlist.dirs = dirlist.store.List()
// 'folders' (if available) is used to make the initial list and
// 'folders-exclude' removes from that list.
configFolders := dirlist.acctConf.Folders
- dirlist.dirs = filterDirs(dirlist.dirs, configFolders, false)
+ dirlist.dirs = dirlist.FilterDirs(dirlist.dirs, configFolders, false)
configFoldersExclude := dirlist.acctConf.FoldersExclude
- dirlist.dirs = filterDirs(dirlist.dirs, configFoldersExclude, true)
+ dirlist.dirs = dirlist.FilterDirs(dirlist.dirs, configFoldersExclude, true)
+}
+
+// FilterDirs filters directories by the supplied filter. If exclude is false,
+// the filter will only include directories from orig which exist in filters.
+// If exclude is true, the directories in filters are removed from orig
+func (dirlist *DirectoryList) FilterDirs(orig, filters []string, exclude bool) []string {
+ if len(filters) == 0 {
+ return orig
+ }
+ var dest []string
+ for _, folder := range orig {
+ // When excluding, include things by default, and vice-versa
+ include := exclude
+ for _, f := range filters {
+ if folderMatches(folder, f) {
+ // If matched an exclusion, don't include
+ // If matched an inclusion, do include
+ include = !exclude
+ break
+ }
+ }
+ if include {
+ dest = append(dest, folder)
+ }
+ }
+ return dest
}
func (dirlist *DirectoryList) SelectedMsgStore() (*lib.MessageStore, bool) {