Private
Public Access
1
0

fix: usr: do not hide the end-game overlay ever #8

This commit is contained in:
2026-04-21 08:48:44 +02:00
parent 20a969705d
commit 0d04ec91e7
3 changed files with 10 additions and 5 deletions

View File

@@ -23,11 +23,13 @@ const GridControl = ({ gameAssoc, onClick, resign }) => {
const [copied, setCopied] = useState(false); const [copied, setCopied] = useState(false);
const shareUrl = gameAssoc ? `${window.location.origin}/play/${gameAssoc}` : null; 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 isAuthenticated = '1' === document.getElementById('mine-wrapper')?.dataset.isAuthenticated;
const handleShare = () => { const handleShare = () => {
if (!shareUrl) return; const url = endRef.current ? endShareUrl : shareUrl;
navigator.clipboard.writeText(shareUrl).then(() => { if (!url) return;
navigator.clipboard.writeText(url).then(() => {
setCopied(true); setCopied(true);
setTimeout(() => setCopied(false), 2200); setTimeout(() => setCopied(false), 2200);
}); });

View File

@@ -218,7 +218,10 @@ export const GameProvider = ({ children }) => {
if (redWins || blueWins || resign) { if (redWins || blueWins || resign) {
sounds.current.won.play(); 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); showLeftMines(leftMines);
syncActivePlayer(false); syncActivePlayer(false);

View File

@@ -211,7 +211,7 @@ const useServerCommunication = (gameAssoc, gameInherited, opponentName, isEnvDev
* For a truly restored game, keep the "Waiting for opponent..." overlay * For a truly restored game, keep the "Waiting for opponent..." overlay
* up until we actually see a heartbeat from the other player. * 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(); hideOverlay();
} }
}; };
@@ -366,7 +366,7 @@ const useServerCommunication = (gameAssoc, gameInherited, opponentName, isEnvDev
if (me && payload.color && payload.color !== me) { if (me && payload.color && payload.color !== me) {
const wasFirst = 0 === opponentLastSeenRef.current; const wasFirst = 0 === opponentLastSeenRef.current;
opponentLastSeenRef.current = Date.now(); opponentLastSeenRef.current = Date.now();
if (wasFirst && isTrueRestoredRef.current) { if (wasFirst && isTrueRestoredRef.current && !endRef.current) {
hideOverlay(); hideOverlay();
} }
} }