diff --git a/assets/js/mine-seeker/components/grid/GridControl.jsx b/assets/js/mine-seeker/components/grid/GridControl.jsx index 46a72d9..7fb8dbe 100644 --- a/assets/js/mine-seeker/components/grid/GridControl.jsx +++ b/assets/js/mine-seeker/components/grid/GridControl.jsx @@ -23,11 +23,13 @@ const GridControl = ({ gameAssoc, onClick, resign }) => { const [copied, setCopied] = useState(false); const shareUrl = gameAssoc ? `${window.location.origin}/play/${gameAssoc}` : null; + const endShareUrl = gameAssoc ? `${window.location.origin}/battle/${gameAssoc}` : null; const isAuthenticated = '1' === document.getElementById('mine-wrapper')?.dataset.isAuthenticated; const handleShare = () => { - if (!shareUrl) return; - navigator.clipboard.writeText(shareUrl).then(() => { + const url = endRef.current ? endShareUrl : shareUrl; + if (!url) return; + navigator.clipboard.writeText(url).then(() => { setCopied(true); setTimeout(() => setCopied(false), 2200); }); diff --git a/assets/js/mine-seeker/contexts/GameProvider.jsx b/assets/js/mine-seeker/contexts/GameProvider.jsx index 37dde5a..bce35f6 100644 --- a/assets/js/mine-seeker/contexts/GameProvider.jsx +++ b/assets/js/mine-seeker/contexts/GameProvider.jsx @@ -218,7 +218,10 @@ export const GameProvider = ({ children }) => { if (redWins || blueWins || resign) { sounds.current.won.play(); - if (!resign) showOverlay((redWins ? 'Red' : 'Blue') + ' wins the game!', 'Play again!'); + if (!resign) { + endRef.current = true; + showOverlay((redWins ? 'Red' : 'Blue') + ' wins the game!', null); + } showLeftMines(leftMines); syncActivePlayer(false); diff --git a/assets/js/mine-seeker/hooks/useServerCommunication.jsx b/assets/js/mine-seeker/hooks/useServerCommunication.jsx index 010cf53..ff47227 100644 --- a/assets/js/mine-seeker/hooks/useServerCommunication.jsx +++ b/assets/js/mine-seeker/hooks/useServerCommunication.jsx @@ -211,7 +211,7 @@ const useServerCommunication = (gameAssoc, gameInherited, opponentName, isEnvDev * For a truly restored game, keep the "Waiting for opponent..." overlay * up until we actually see a heartbeat from the other player. */ - if (!isTrueRestoredRef.current || 0 !== opponentLastSeenRef.current) { + if (!endRef.current && (!isTrueRestoredRef.current || 0 !== opponentLastSeenRef.current)) { hideOverlay(); } }; @@ -366,7 +366,7 @@ const useServerCommunication = (gameAssoc, gameInherited, opponentName, isEnvDev if (me && payload.color && payload.color !== me) { const wasFirst = 0 === opponentLastSeenRef.current; opponentLastSeenRef.current = Date.now(); - if (wasFirst && isTrueRestoredRef.current) { + if (wasFirst && isTrueRestoredRef.current && !endRef.current) { hideOverlay(); } }