diff --git a/race_control.go b/race_control.go index 099e62830..2acb078d5 100644 --- a/race_control.go +++ b/race_control.go @@ -233,6 +233,11 @@ func (rc *RaceControl) watchForTimedOutDrivers() { func (rc *RaceControl) OnVersion(version udp.Version) error { go panicCapture(rc.requestSessionInfo) + // clear chat messages on new server start + rc.ChatMessagesMutex.Lock() + rc.ChatMessages = []udp.Chat{} + rc.ChatMessagesMutex.Unlock() + _, err := rc.broadcaster.Send(version) return err diff --git a/race_manager.go b/race_manager.go index f36ac059c..f689c15ab 100644 --- a/race_manager.go +++ b/race_manager.go @@ -1095,7 +1095,7 @@ func (rm *RaceManager) BuildRaceOpts(r *http.Request) (*RaceTemplateVars, error) return opts, nil } -const maxRecentRaces = 30 +const maxRecentRaces = 40 func (rm *RaceManager) ListCustomRaces() (recent, starred, looped, scheduled []*CustomRace, err error) { recent, err = rm.store.ListCustomRaces() @@ -1110,8 +1110,6 @@ func (rm *RaceManager) ListCustomRaces() (recent, starred, looped, scheduled []* return recent[i].Updated.After(recent[j].Updated) }) - var filteredRecent []*CustomRace - for _, race := range recent { if race.IsLooping() { looped = append(looped, race) @@ -1142,17 +1140,13 @@ func (rm *RaceManager) ListCustomRaces() (recent, starred, looped, scheduled []* if race.Scheduled.After(time.Now()) && race.ScheduledServerID == serverID { scheduled = append(scheduled, race) } - - if !race.Starred && !race.IsLooping() && !race.Scheduled.After(time.Now()) { - filteredRecent = append(filteredRecent, race) - } } - if len(filteredRecent) > maxRecentRaces { - filteredRecent = filteredRecent[:maxRecentRaces] + if len(recent) > maxRecentRaces { + recent = recent[:maxRecentRaces] } - return filteredRecent, starred, looped, scheduled, nil + return recent, starred, looped, scheduled, nil } func (rm *RaceManager) SaveEntrantsForAutoFill(entryList EntryList) error {