aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2023-02-03 00:01:26 +0100
committerRobin Jarry <robin@jarry.cc>2023-02-20 14:44:37 +0100
commit87e3d4bafa9f1b8e91172c135644783de548e35b (patch)
treef41ed64a68f2e57cccb64b326a0095d1d140cb8b /lib
parenta5df5c30b62aae0b2f9d54e6f40fab76999c565b (diff)
downloadaerc-87e3d4bafa9f1b8e91172c135644783de548e35b.tar.gz
templates: add message counts for specific folders
Change the {{.Recent}}, {{.Unread}} and {{.Exists}} template fields to take an arbitrary number of folder names as arguments. If no folder name is specified, these return the counts for all folders. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/state/templates.go19
1 files changed, 11 insertions, 8 deletions
diff --git a/lib/state/templates.go b/lib/state/templates.go
index fdf662c5..b199cf25 100644
--- a/lib/state/templates.go
+++ b/lib/state/templates.go
@@ -324,10 +324,13 @@ func (d *TemplateData) OriginalHeader(name string) string {
return text
}
-func (d *TemplateData) rue() (int, int, int) {
+func (d *TemplateData) rue(folders ...string) (int, int, int) {
var recent, unread, exists int
if d.getRUEcount != nil {
- for _, dir := range d.folders {
+ if len(folders) == 0 {
+ folders = d.folders
+ }
+ for _, dir := range folders {
r, u, e := d.getRUEcount(dir)
recent += r
unread += u
@@ -337,17 +340,17 @@ func (d *TemplateData) rue() (int, int, int) {
return recent, unread, exists
}
-func (d *TemplateData) Recent() int {
- r, _, _ := d.rue()
+func (d *TemplateData) Recent(folders ...string) int {
+ r, _, _ := d.rue(folders...)
return r
}
-func (d *TemplateData) Unread() int {
- _, u, _ := d.rue()
+func (d *TemplateData) Unread(folders ...string) int {
+ _, u, _ := d.rue(folders...)
return u
}
-func (d *TemplateData) Exists() int {
- _, _, e := d.rue()
+func (d *TemplateData) Exists(folders ...string) int {
+ _, _, e := d.rue(folders...)
return e
}