From ae675b491d2b55a06588e8ab4ce8205aaae796c8 Mon Sep 17 00:00:00 2001 From: Robin Jarry Date: Tue, 20 Dec 2022 17:05:43 +0100 Subject: 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 Acked-by: Tim Culverhouse --- commands/msg/forward.go | 2 +- commands/msg/invite.go | 2 +- commands/msg/recall.go | 2 +- commands/msg/reply.go | 3 ++- commands/msg/unsubscribe.go | 3 +-- 5 files changed, 6 insertions(+), 6 deletions(-) (limited to 'commands/msg') diff --git a/commands/msg/forward.go b/commands/msg/forward.go index 9a4f3d41..90c32ec2 100644 --- a/commands/msg/forward.go +++ b/commands/msg/forward.go @@ -101,7 +101,7 @@ func (forward) Execute(aerc *widgets.Aerc, args []string) error { addTab := func() (*widgets.Composer, error) { composer, err := widgets.NewComposer(aerc, acct, - acct.AccountConfig(), acct.Worker(), template, h, original) + acct.AccountConfig(), acct.Worker(), template, h, &original) if err != nil { aerc.PushError("Error: " + err.Error()) return nil, err diff --git a/commands/msg/invite.go b/commands/msg/invite.go index ef28b91c..1528abea 100644 --- a/commands/msg/invite.go +++ b/commands/msg/invite.go @@ -139,7 +139,7 @@ func (invite) Execute(aerc *widgets.Aerc, args []string) error { addTab := func(cr *calendar.Reply) error { composer, err := widgets.NewComposer(aerc, acct, - acct.AccountConfig(), acct.Worker(), "", h, original) + acct.AccountConfig(), acct.Worker(), "", h, &original) if err != nil { aerc.PushError("Error: " + err.Error()) return err diff --git a/commands/msg/recall.go b/commands/msg/recall.go index f106e8bd..2ef468e0 100644 --- a/commands/msg/recall.go +++ b/commands/msg/recall.go @@ -74,7 +74,7 @@ func (Recall) Execute(aerc *widgets.Aerc, args []string) error { composer, err := widgets.NewComposer(aerc, acct, acct.AccountConfig(), acct.Worker(), "", msgInfo.RFC822Headers, - models.OriginalMail{}) + nil) if err != nil { return errors.Wrap(err, "Cannot open a new composer") } diff --git a/commands/msg/reply.go b/commands/msg/reply.go index 795158ca..f8cde644 100644 --- a/commands/msg/reply.go +++ b/commands/msg/reply.go @@ -175,7 +175,8 @@ func (reply) Execute(aerc *widgets.Aerc, args []string) error { mv, _ := aerc.SelectedTabContent().(*widgets.MessageViewer) addTab := func() error { composer, err := widgets.NewComposer(aerc, acct, - acct.AccountConfig(), acct.Worker(), template, h, original) + acct.AccountConfig(), acct.Worker(), template, h, + &original) if err != nil { aerc.PushError("Error: " + err.Error()) return err diff --git a/commands/msg/unsubscribe.go b/commands/msg/unsubscribe.go index a334e827..66797660 100644 --- a/commands/msg/unsubscribe.go +++ b/commands/msg/unsubscribe.go @@ -11,7 +11,6 @@ import ( "git.sr.ht/~rjarry/aerc/lib" "git.sr.ht/~rjarry/aerc/lib/ui" "git.sr.ht/~rjarry/aerc/log" - "git.sr.ht/~rjarry/aerc/models" "git.sr.ht/~rjarry/aerc/widgets" "github.com/emersion/go-message/mail" ) @@ -155,7 +154,7 @@ func unsubscribeMailto(aerc *widgets.Aerc, u *url.URL) error { acct.Worker(), "", h, - models.OriginalMail{}, + nil, ) if err != nil { return err -- cgit