diff options
author | Robin Jarry <robin@jarry.cc> | 2022-12-20 17:05:43 +0100 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2023-01-04 22:57:31 +0100 |
commit | ae675b491d2b55a06588e8ab4ce8205aaae796c8 (patch) | |
tree | 383920e34344ea3456162fb74cc180bfb33dec83 /widgets | |
parent | 2a290cf1ed6113f0d01eea3f2cff446339bed0ce (diff) | |
download | aerc-ae675b491d2b55a06588e8ab4ce8205aaae796c8.tar.gz |
templates: change fields as lazy functions
No need to pre-render fields that are not necessarily accessed in
templates. Change fields to functions that are evaluated only when
required.
Signed-off-by: Robin Jarry <robin@jarry.cc>
Acked-by: Tim Culverhouse <tim@timculverhouse.com>
Diffstat (limited to 'widgets')
-rw-r--r-- | widgets/aerc.go | 3 | ||||
-rw-r--r-- | widgets/compose.go | 6 |
2 files changed, 4 insertions, 5 deletions
diff --git a/widgets/aerc.go b/widgets/aerc.go index f6e5c1ff..eb904ea0 100644 --- a/widgets/aerc.go +++ b/widgets/aerc.go @@ -20,7 +20,6 @@ import ( "git.sr.ht/~rjarry/aerc/lib/crypto" "git.sr.ht/~rjarry/aerc/lib/ui" "git.sr.ht/~rjarry/aerc/log" - "git.sr.ht/~rjarry/aerc/models" "git.sr.ht/~rjarry/aerc/worker/types" ) @@ -710,7 +709,7 @@ func (aerc *Aerc) Mailto(addr *url.URL) error { } composer, err := NewComposer(aerc, acct, - acct.AccountConfig(), acct.Worker(), "", h, models.OriginalMail{}) + acct.AccountConfig(), acct.Worker(), "", h, nil) if err != nil { return nil } diff --git a/widgets/compose.go b/widgets/compose.go index 782e7538..c59fa8ef 100644 --- a/widgets/compose.go +++ b/widgets/compose.go @@ -33,7 +33,7 @@ type Composer struct { sync.Mutex editors map[string]*headerEditor // indexes in lower case (from / cc / bcc) header *mail.Header - parent models.OriginalMail // parent of current message, only set if reply + parent *models.OriginalMail // parent of current message, only set if reply acctConfig *config.AccountConfig acct *AccountView @@ -68,7 +68,7 @@ type Composer struct { func NewComposer( aerc *Aerc, acct *AccountView, acctConfig *config.AccountConfig, worker *types.Worker, template string, - h *mail.Header, orig models.OriginalMail, + h *mail.Header, orig *models.OriginalMail, ) (*Composer, error) { if h == nil { h = new(mail.Header) @@ -93,7 +93,7 @@ func NewComposer( completer: nil, } - templateData := templates.ParseTemplateData(h, orig) + templateData := templates.NewTemplateData(h, orig) if err := c.AddTemplate(template, templateData); err != nil { return nil, err } |