[times] Don't panic when failing to get time track logs

This commit is contained in:
Noah 2024-03-17 17:59:42 -05:00
parent 651e6ac7dc
commit dfeef3e271

View File

@ -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
}
@ -49,6 +49,7 @@ type indicator struct {
quitting bool
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)
}