From dfeef3e271a456de724b2de27937f26d76772761 Mon Sep 17 00:00:00 2001 From: Noah Date: Sun, 17 Mar 2024 17:59:42 -0500 Subject: [PATCH] [times] Don't panic when failing to get time track logs --- times.go | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/times.go b/times.go index c33a35e..1d4637a 100644 --- a/times.go +++ b/times.go @@ -5,20 +5,20 @@ import ( "os" "time" - "github.com/charmbracelet/bubbles/table" "github.com/charmbracelet/bubbles/spinner" + "github.com/charmbracelet/bubbles/table" tea "github.com/charmbracelet/bubbletea" "github.com/charmbracelet/lipgloss" "code.gitea.io/sdk/gitea" ) - var helpStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#626262")).Render type timesviewer struct { table table.Model } + func (m timesviewer) Init() tea.Cmd { return nil } @@ -45,10 +45,11 @@ func (m timesviewer) View() string { } type indicator struct { - spinner spinner.Model + spinner spinner.Model quitting bool - err error + err error } + func initialIndicator() indicator { s := spinner.New() s.Spinner = spinner.Dot @@ -105,10 +106,14 @@ func times() { if repo.Fork { continue } - repo_times, _, err := client.ListRepoTrackedTimes(repo.Owner.UserName, repo.Name, gitea.ListTrackedTimesOptions{User: user.UserName, Since: since}) - if err != nil { - panic(err) - } + repo_times, _, _ := client.ListRepoTrackedTimes( + repo.Owner.UserName, + repo.Name, + gitea.ListTrackedTimesOptions{ + User: user.UserName, + Since: since, + }, + ) for _, t := range repo_times { times = append(times, *t) } @@ -125,7 +130,7 @@ func times() { } rows := []table.Row{} for _, t := range times { - dur, err := time.ParseDuration(fmt.Sprint(t.Time)+"s") + dur, err := time.ParseDuration(fmt.Sprint(t.Time) + "s") if err != nil { panic(err) }