diff options
author | Robin Jarry <robin@jarry.cc> | 2023-10-10 00:08:31 +0200 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2023-10-10 11:38:01 +0200 |
commit | bc176bd61ba726351a489cabf4da16a47dc5ec3b (patch) | |
tree | bbf06f731592d072f3d6f76f1648d61989375f2e /commands/msg/recall.go | |
parent | 598e4a5803578ab3e291f232d6aad31b4efd8ea4 (diff) | |
download | aerc-bc176bd61ba726351a489cabf4da16a47dc5ec3b.tar.gz |
app: export global functions
The single Aerc object is passed around in almost all command functions.
This hinders readability.
Store the single Aerc instance as a global variable. Export public
functions from the app package to access methods of that object. Remove
all explicit references to *app.Aerc and replace them with calls to
these functions. For references to private/unexported fields and
functions from within the app package, directly access the global aerc
object.
Signed-off-by: Robin Jarry <robin@jarry.cc>
Acked-by: Moritz Poldrack <moritz@poldrack.dev>
Diffstat (limited to 'commands/msg/recall.go')
-rw-r--r-- | commands/msg/recall.go | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/commands/msg/recall.go b/commands/msg/recall.go index 4a08df29..2d999b1d 100644 --- a/commands/msg/recall.go +++ b/commands/msg/recall.go @@ -28,11 +28,11 @@ func (Recall) Aliases() []string { return []string{"recall"} } -func (Recall) Complete(aerc *app.Aerc, args []string) []string { +func (Recall) Complete(args []string) []string { return nil } -func (Recall) Execute(aerc *app.Aerc, args []string) error { +func (Recall) Execute(args []string) error { force := false editHeaders := config.Compose.EditHeaders @@ -54,7 +54,7 @@ func (Recall) Execute(aerc *app.Aerc, args []string) error { return errors.New("Usage: recall [-f] [-e|-E]") } - widget := aerc.SelectedTabContent().(app.ProvidesMessage) + widget := app.SelectedTabContent().(app.ProvidesMessage) acct := widget.SelectedAccount() if acct == nil { return errors.New("No account selected") @@ -79,7 +79,7 @@ func (Recall) Execute(aerc *app.Aerc, args []string) error { if subject == "" { subject = "Recalled email" } - composer.Tab = aerc.NewTab(composer, subject) + composer.Tab = app.NewTab(composer, subject) composer.OnClose(func(composer *app.Composer) { worker := composer.Worker() uids := []uint32{msgInfo.Uid} @@ -90,9 +90,9 @@ func (Recall) Execute(aerc *app.Aerc, args []string) error { }, func(msg types.WorkerMessage) { switch msg := msg.(type) { case *types.Done: - aerc.PushStatus("Recalled message deleted", 10*time.Second) + app.PushStatus("Recalled message deleted", 10*time.Second) case *types.Error: - aerc.PushError(msg.Error.Error()) + app.PushError(msg.Error.Error()) } }) } @@ -104,10 +104,10 @@ func (Recall) Execute(aerc *app.Aerc, args []string) error { } lib.NewMessageStoreView(msgInfo, acct.UiConfig().AutoMarkRead, - store, aerc.Crypto, aerc.DecryptKeys, + store, app.CryptoProvider(), app.DecryptKeys, func(msg lib.MessageView, err error) { if err != nil { - aerc.PushError(err.Error()) + app.PushError(err.Error()) return } var path []int @@ -116,11 +116,11 @@ func (Recall) Execute(aerc *app.Aerc, args []string) error { } msg.FetchBodyPart(path, func(reader io.Reader) { - composer, err := app.NewComposer(aerc, acct, + composer, err := app.NewComposer(acct, acct.AccountConfig(), acct.Worker(), editHeaders, "", msgInfo.RFC822Headers, nil, reader) if err != nil { - aerc.PushError(err.Error()) + app.PushError(err.Error()) return } if md := msg.MessageDetails(); md != nil { @@ -159,7 +159,7 @@ func (Recall) Execute(aerc *app.Aerc, args []string) error { mu.Unlock() if err != nil { log.Errorf(err.Error()) - aerc.PushError(err.Error()) + app.PushError(err.Error()) } }) } |