Skip to content

Commit

Permalink
fix: crash on races without data
Browse files Browse the repository at this point in the history
  • Loading branch information
acifani committed Apr 30, 2023
1 parent 3990556 commit a5b742f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/acifani/formula1-go

go 1.18
go 1.20

require (
github.com/charmbracelet/bubbles v0.14.0
Expand Down
6 changes: 5 additions & 1 deletion internal/ui/quali/quali.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,11 @@ func (m model) View() string {
func LoadResults(year, round string) tea.Cmd {
return func() tea.Msg {
results, err := api.GetQualifyingResult(year, round)
return LoadDone{data: results, err: err}
if len(results.Races) > 0 {
return LoadDone{data: results, err: err}
}

return nil
}
}

Expand Down
6 changes: 5 additions & 1 deletion internal/ui/results/results.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,11 @@ func fetchRows() tea.Msg {
func LoadResults(year, round string) tea.Cmd {
return func() tea.Msg {
results, err := api.GetRaceResult(year, round)
return LoadDone{data: results, err: err}
if len(results.Races) > 0 {
return LoadDone{data: results, err: err}
}

return nil
}
}

Expand Down

0 comments on commit a5b742f

Please sign in to comment.