Skip to content

Commit 20046c9

Browse files
committed
fix[live]: unique upcoming matches only
1 parent ef885c2 commit 20046c9

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

internal/app/update.go

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -632,11 +632,23 @@ func (m model) handleStatsDayData(msg statsDayDataMsg) (tea.Model, tea.Cmd) {
632632
}
633633
}
634634

635-
// Add upcoming matches (only from today)
635+
// Add upcoming matches (only from today), deduplicated by match ID
636636
if msg.isToday && len(msg.upcoming) > 0 {
637-
m.statsData.TodayUpcoming = append(m.statsData.TodayUpcoming, msg.upcoming...)
637+
// Build a set of existing IDs to avoid duplicates
638+
existingIDs := make(map[int]bool)
639+
for _, match := range m.statsData.TodayUpcoming {
640+
existingIDs[match.ID] = true
641+
}
642+
643+
// Only add matches that aren't already in the list
644+
for _, match := range msg.upcoming {
645+
if !existingIDs[match.ID] {
646+
m.statsData.TodayUpcoming = append(m.statsData.TodayUpcoming, match)
647+
existingIDs[match.ID] = true
648+
}
649+
}
638650

639-
// Also populate liveUpcomingMatches for the live view
651+
// Populate liveUpcomingMatches for the live view
640652
upcomingDisplay := make([]ui.MatchDisplay, 0, len(m.statsData.TodayUpcoming))
641653
for _, match := range m.statsData.TodayUpcoming {
642654
upcomingDisplay = append(upcomingDisplay, ui.MatchDisplay{Match: match})

0 commit comments

Comments
 (0)