diff options
author | Tim Culverhouse <tim@timculverhouse.com> | 2023-04-16 09:53:46 -0500 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2023-04-22 22:40:12 +0200 |
commit | d8c2d63ee9b37e78d0e06ec71b2227b83ee52aa5 (patch) | |
tree | ea71295539f16c1f696dcb2edbca1475d93298a8 /lib | |
parent | 669431702f46eb58f893cbe722040de3792f6b03 (diff) | |
download | aerc-d8c2d63ee9b37e78d0e06ec71b2227b83ee52aa5.tar.gz |
directory: add role to template fields
Add .Role as a template field for use in distinguishing between
mailboxes with a given IANA role, or custom role defined by aerc
("query" for notmuch queries, for example).
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry<robin@jarry.cc>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/state/templates.go | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/lib/state/templates.go b/lib/state/templates.go index f971b62c..e93d0bb0 100644 --- a/lib/state/templates.go +++ b/lib/state/templates.go @@ -29,7 +29,7 @@ type TemplateData struct { // selected account account *config.AccountConfig myAddresses map[string]bool - folder string // selected folder name + folder *models.Directory // selected folder folders []string getRUEcount func(string) (int, int, int) @@ -66,7 +66,7 @@ func (d *TemplateData) SetAccount(acct *config.AccountConfig) { } } -func (d *TemplateData) SetFolder(folder string) { +func (d *TemplateData) SetFolder(folder *models.Directory) { d.folder = folder } @@ -91,11 +91,21 @@ func (d *TemplateData) Account() string { } func (d *TemplateData) Folder() string { - return d.folder + if d.folder != nil { + return d.folder.Name + } + return "" +} + +func (d *TemplateData) Role() string { + if d.folder != nil { + return string(d.folder.Role) + } + return "" } func (d *TemplateData) ui() *config.UIConfig { - return config.Ui.ForAccount(d.Account()).ForFolder(d.folder) + return config.Ui.ForAccount(d.Account()).ForFolder(d.Folder()) } func (d *TemplateData) To() []*mail.Address { @@ -425,7 +435,7 @@ func (d *TemplateData) ContentInfo() string { return "" } var content []string - fldr := d.state.folderState(d.folder) + fldr := d.state.folderState(d.Folder()) if fldr.FilterActivity != "" { content = append(content, fldr.FilterActivity) } else if fldr.Filter != "" { @@ -450,7 +460,7 @@ func (d *TemplateData) TrayInfo() string { return "" } var tray []string - fldr := d.state.folderState(d.folder) + fldr := d.state.folderState(d.Folder()) if fldr.Sorting { tray = append(tray, texter().Sorting()) } |