diff options
author | inwit <inwit@sindominio.net> | 2023-11-09 21:35:04 +0100 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2023-11-12 12:53:11 +0100 |
commit | c13df799763c6b584cf4963e125361bb16c0e07d (patch) | |
tree | 31262c5de8a47ff7b4d1ca9be75924d80c95173d /lib | |
parent | 063187340ce257a633cc5e6b503112db306be2e6 (diff) | |
download | aerc-c13df799763c6b584cf4963e125361bb16c0e07d.tar.gz |
threads: add .ThreadUnread to template data
When a thread is folded, it can be useful to know how many unseen
messages lie below the root. For example, one might want to show that
count in the message list:
column-folded = {{if .ThreadFolded \
}}{{if ne .ThreadUnread 0 \
}}{{.ThreadUnread | printf "%s/"}}{{ \
end}}{{ .ThreadCount | printf "%s"}}{{end}}
Add `.ThreadUnread` to the template functions.
Changelog-added: `.ThreadUnread` is now available in templates.
Signed-off-by: inwit <inwit@sindominio.net>
Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/state/templates.go | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/state/templates.go b/lib/state/templates.go index 92a25b72..e8c50e86 100644 --- a/lib/state/templates.go +++ b/lib/state/templates.go @@ -21,7 +21,7 @@ type DataSetter interface { Data() models.TemplateData SetHeaders(*mail.Header, *models.OriginalMail) SetInfo(*models.MessageInfo, int, bool) - SetThreading(string, bool, int, bool, bool) + SetThreading(string, bool, int, int, bool, bool) SetComposer(Composer) SetAccount(*config.AccountConfig) SetFolder(*models.Directory) @@ -34,6 +34,7 @@ type ThreadInfo struct { SameSubject bool Prefix string Count int + Unread int Folded bool Context bool } @@ -88,11 +89,12 @@ func (d *templateData) SetInfo(info *models.MessageInfo, num int, marked bool, } func (d *templateData) SetThreading(prefix string, same bool, count int, - folded bool, context bool, + unread int, folded bool, context bool, ) { d.threadInfo.Prefix = prefix d.threadInfo.SameSubject = same d.threadInfo.Count = count + d.threadInfo.Unread = unread d.threadInfo.Folded = folded d.threadInfo.Context = context } @@ -301,6 +303,10 @@ func (d *templateData) ThreadCount() int { return d.threadInfo.Count } +func (d *templateData) ThreadUnread() int { + return d.threadInfo.Unread +} + func (d *templateData) ThreadFolded() bool { return d.threadInfo.Folded } |