diff --git a/src/App.tsx b/src/App.tsx index e302ace..9f5936b 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -15,6 +15,9 @@ import { TradeDesk } from './TradeDesk.tsx'; import { IS_MAINNET, NETWORK_GENESIS_TIME, NETWORK_LABEL } from '../shared/network.ts'; import { StateClient } from '../shared/rpc-client.ts'; import { PlaySection } from './game/PlaySection.tsx'; +import { inviteFromPath } from './game/online.ts'; +import { BattleRecap, matchIdFromPath } from './game/recap/BattleRecap.tsx'; +import './game/recap/recap.css'; import { isNativeApp } from './native.ts'; import { Landing } from './Landing.tsx'; import './App.css'; @@ -47,7 +50,17 @@ function transferProblem(state: TestnetSnapshot, card: CardData, address: string } export default function App() { - const [view, setView] = useState('Discover'); + // Deep links (Night 2, ui-pvp): /play/invite/ opens Play with the invite; /battle/ is a recap page. + const [invite] = useState(() => inviteFromPath(location.pathname)); + const [battle, setBattle] = useState(() => matchIdFromPath(location.pathname)); + const [view, setView] = useState(() => (invite ? 'Play' : 'Discover')); + const openRecap = (id: string) => { history.pushState(null, '', `/battle/${encodeURIComponent(id)}`); setBattle(id); }; + const closeRecap = () => { history.pushState(null, '', '/'); setBattle(''); }; + useEffect(() => { + const pop = () => setBattle(matchIdFromPath(location.pathname)); + window.addEventListener('popstate', pop); + return () => window.removeEventListener('popstate', pop); + }, []); const [wallet, setWallet] = useState(); const [snapshot, setSnapshot] = useState(); const [rpcAvailable, setRpcAvailable] = useState(false); @@ -161,6 +174,8 @@ export default function App() { catch (e) { setError(message(e)); } }; + // /battle/: a standalone, shareable recap page (no hero or mining panel around it). + if (battle) return
; return