Load all competition emblems upfront so picker shows logos immediately

Previously emblems were only cached after visiting each competition.
Now a single /api/competitions fetch on mount populates all emblems
at once, including the initially selected button.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-15 06:45:27 +01:00
parent 0209aa806e
commit 36474d3525

View File

@@ -18,6 +18,19 @@ export default function App() {
const closeModal = useCallback(() => setSelectedTeam(null), [])
// Load all competition emblems once on mount so the picker shows logos immediately
useEffect(() => {
apiFetch('/competitions')
.then((data) => {
const map = {}
for (const comp of data.competitions ?? []) {
if (comp.code && comp.emblem) map[comp.code] = comp.emblem
}
setEmblems(map)
})
.catch(() => {}) // non-critical — picker still works without logos
}, [])
useEffect(() => {
setLoading(true)
setError(null)
@@ -30,10 +43,6 @@ export default function App() {
setStandings(total?.table ?? [])
setCompetition(data.competition)
setSeason(data.season)
// Cache the emblem for this competition
if (data.competition?.emblem) {
setEmblems((prev) => ({ ...prev, [selectedCode]: data.competition.emblem }))
}
setLoading(false)
})
.catch((err) => {