From d1a76d38823e2ada4eb30e175a17471550017900 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sun, 28 Jul 2024 23:11:17 +0300 Subject: refactor --- internal/client/tui/submit.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'internal/client/tui/submit.go') diff --git a/internal/client/tui/submit.go b/internal/client/tui/submit.go index 3d908a0..574fb54 100644 --- a/internal/client/tui/submit.go +++ b/internal/client/tui/submit.go @@ -17,23 +17,23 @@ func submitAction(ctx context.Context, conf config.ClientConfig) tea.Cmd { composeFile := fmt.Sprintf("%s/%s", conf.DataDir, conf.ComposeFile) return submitEntry(ctx, conf, composeFile, func() error { - // This is the callback to call when the entry was submitted succesfully + // This is the cb to call when the entry was submitted succesfully timestamp := time.Now().Format("20060102-150405") submittedFile := fmt.Sprintf("%s/submitted-%s.txt", conf.DataDir, timestamp) return os.Rename(composeFile, submittedFile) }) } -func submitEntry(ctx context.Context, conf client.ClientConfig, filePath string, callback func() error) tea.Cmd { +func submitEntry(ctx context.Context, conf client.ClientConfig, filePath string, cb func() error) tea.Cmd { servers, err := conf.Servers() if err != nil { - return finished(callback, err) + return finished(cb, err) } ent, err := types.NewEntryFromTextFile(filePath) if err != nil { - return finished(callback, err) + return finished(cb, err) } - return finished(callback, easyhttp.PostData(ctx, "submit", conf.APIKey, &ent, servers...)) + return finished(cb, easyhttp.PostData(ctx, "submit", conf.APIKey, &ent, servers...)) } -- cgit v1.2.3