@@ -10,9 +10,12 @@ import (
1010 "github.com/adrunkhuman/90minuTUI/internal/site"
1111)
1212
13+ // cmdTimeout is generous enough for slow archive pages without blocking the TUI indefinitely.
14+ const cmdTimeout = 20 * time .Second
15+
1316func (m Model ) loadArchiveCmd (url string ) tea.Cmd {
1417 return func () tea.Msg {
15- ctx , cancel := context .WithTimeout (context .Background (), 20 * time . Second )
18+ ctx , cancel := context .WithTimeout (context .Background (), cmdTimeout )
1619 defer cancel ()
1720 seasons , selectedIdx , competitions , err := m .service .LoadArchive (ctx , url )
1821 return archiveLoadedMsg {seasons : seasons , selectedIdx : selectedIdx , competitions : competitions , err : err }
@@ -21,7 +24,7 @@ func (m Model) loadArchiveCmd(url string) tea.Cmd {
2124
2225func (m Model ) loadSeasonCompetitionsCmd (url , seasonKey string ) tea.Cmd {
2326 return func () tea.Msg {
24- ctx , cancel := context .WithTimeout (context .Background (), 20 * time . Second )
27+ ctx , cancel := context .WithTimeout (context .Background (), cmdTimeout )
2528 defer cancel ()
2629 _ , _ , competitions , err := m .service .LoadArchive (ctx , url )
2730 return competitionsLoadedMsg {seasonKey : seasonKey , competitions : competitions , err : err }
@@ -30,7 +33,7 @@ func (m Model) loadSeasonCompetitionsCmd(url, seasonKey string) tea.Cmd {
3033
3134func (m Model ) loadCompetitionCmd (url , competitionKey string ) tea.Cmd {
3235 return func () tea.Msg {
33- ctx , cancel := context .WithTimeout (context .Background (), 20 * time . Second )
36+ ctx , cancel := context .WithTimeout (context .Background (), cmdTimeout )
3437 defer cancel ()
3538 menu , league , err := m .service .LoadCompetition (ctx , url )
3639 return competitionMenuLoadedMsg {competitionKey : competitionKey , menu : menu , league : league , err : err }
@@ -39,7 +42,7 @@ func (m Model) loadCompetitionCmd(url, competitionKey string) tea.Cmd {
3942
4043func (m Model ) loadLeagueCmd (url , competitionKey string ) tea.Cmd {
4144 return func () tea.Msg {
42- ctx , cancel := context .WithTimeout (context .Background (), 20 * time . Second )
45+ ctx , cancel := context .WithTimeout (context .Background (), cmdTimeout )
4346 defer cancel ()
4447 league , err := m .service .LoadLeague (ctx , url )
4548 return leagueLoadedMsg {competitionKey : competitionKey , league : league , err : err }
@@ -48,7 +51,7 @@ func (m Model) loadLeagueCmd(url, competitionKey string) tea.Cmd {
4851
4952func (m Model ) loadMatchCmd (url , fixtureKey string ) tea.Cmd {
5053 return func () tea.Msg {
51- ctx , cancel := context .WithTimeout (context .Background (), 20 * time . Second )
54+ ctx , cancel := context .WithTimeout (context .Background (), cmdTimeout )
5255 defer cancel ()
5356 match , err := m .service .LoadMatch (ctx , url )
5457 return matchLoadedMsg {fixtureKey : fixtureKey , match : match , err : err }
0 commit comments