ai generated solutions to our ai generated problems

This commit is contained in:
2026-06-20 00:50:28 +01:00
parent 22bff51147
commit 50439720dd
4 changed files with 86 additions and 255 deletions
+4 -21
View File
@@ -1074,28 +1074,11 @@ function GatedAppContent() {
}
function AppContent() {
const bootData = window.__TSS_BOOT_DATA__ || {}
const [route, setRoute] = useState(() => parseRoute())
const [leaderboard, setLeaderboard] = useState(() => (
bootData.leaderboard
? { status: 'ready', data: bootData.leaderboard, error: null }
: { status: 'idle', data: null, error: null }
))
const [playerLeaderboard, setPlayerLeaderboard] = useState(() => (
bootData.playerLeaderboard
? { status: 'ready', data: bootData.playerLeaderboard, error: null }
: { status: 'idle', data: null, error: null }
))
const [homeTeams, setHomeTeams] = useState(() => (
bootData.homeTeams
? { status: 'ready', data: bootData.homeTeams, error: null }
: { status: 'idle', data: null, error: null }
))
const [live, setLive] = useState(() => (
bootData.live
? { status: 'ready', data: bootData.live, error: null, updatedAt: Date.now() }
: { status: 'idle', data: null, error: null, updatedAt: 0 }
))
const [leaderboard, setLeaderboard] = useState({ status: 'idle', data: null, error: null })
const [playerLeaderboard, setPlayerLeaderboard] = useState({ status: 'idle', data: null, error: null })
const [homeTeams, setHomeTeams] = useState({ status: 'idle', data: null, error: null })
const [live, setLive] = useState({ status: 'idle', data: null, error: null, updatedAt: 0 })
const [uptime, setUptime] = useState({ status: 'idle', checks: [], history: [], updatedAt: null })
const [viewers, setViewers] = useState({ status: 'idle', data: null, error: null, updatedAt: null })
const [analyticsPreferences, setAnalyticsPreferences] = useState(() => storedAnalyticsPreferences())
+1 -50
View File
@@ -2,53 +2,4 @@ import { createRoot } from 'react-dom/client'
import './styles.css'
import App from './App.jsx'
const root = document.getElementById('root')
async function fetchBootJson(path) {
const response = await fetch(path, { headers: { Accept: 'application/json' } })
if (!response.ok) throw new Error(`Boot request failed with ${response.status}`)
return response.json()
}
async function preloadBootData() {
if (!root?.dataset.tssFallback) return
const pathname = window.location.pathname
const timeout = new Promise((_, reject) => {
window.setTimeout(() => reject(new Error('Boot preload timed out')), 1500)
})
const load = async () => {
if (pathname === '/') {
const [homeTeams, live] = await Promise.all([
fetchBootJson('/data/home-teams.json'),
fetchBootJson('/data/recent-games.json'),
])
return { homeTeams, live }
}
if (pathname === '/teams') {
return { leaderboard: await fetchBootJson('/data/leaderboard-teams.json') }
}
if (pathname === '/players') {
return { playerLeaderboard: await fetchBootJson('/data/leaderboard-players.json') }
}
if (pathname === '/battle-logs' || pathname === '/live') {
const [live, leaderboard] = await Promise.all([
fetchBootJson('/data/recent-games.json'),
fetchBootJson('/data/leaderboard-teams.json'),
])
return { live, leaderboard }
}
return null
}
window.__TSS_BOOT_DATA__ = await Promise.race([load(), timeout]).catch(() => null)
}
preloadBootData().finally(() => {
createRoot(root).render(<App />)
})
createRoot(document.getElementById('root')).render(<App />)