From 87e3d4bafa9f1b8e91172c135644783de548e35b Mon Sep 17 00:00:00 2001 From: Robin Jarry Date: Fri, 3 Feb 2023 00:01:26 +0100 Subject: 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 Acked-by: Tim Culverhouse --- lib/state/templates.go | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'lib') 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 } -- cgit