From 5d834db3eda9f5a6f776dc231d775ce73a0d9c36 Mon Sep 17 00:00:00 2001 From: Jonas Tranberg Date: Sun, 28 Jul 2024 17:01:54 +0200 Subject: [PATCH] don't show finish dialog in offline games --- src/views/Game/components/Header.tsx | 14 +++++++++++++- src/views/Game/index.tsx | 5 ++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/views/Game/components/Header.tsx b/src/views/Game/components/Header.tsx index b65caad..1404d4e 100644 --- a/src/views/Game/components/Header.tsx +++ b/src/views/Game/components/Header.tsx @@ -59,6 +59,18 @@ const Header: FunctionComponent = () => { const [exitGameDialogOpen, setExitGameDialogOpen] = useState(false); const [dnfDialogOpen, setDNFDialogOpen] = useState(false); + const showExitGameDialog = () => { + if (game.offline && gameMetrics.done) { + game.ExitGame({ + dnf: false, + }); + + return; + } + + setExitGameDialogOpen(true); + }; + const closeExitGameDialog = (e: { ok: boolean }) => { setExitGameDialogOpen(false); @@ -254,7 +266,7 @@ const Header: FunctionComponent = () => { sx={{ color: "primary.contrastText", }} - onClick={() => setExitGameDialogOpen(true)} + onClick={showExitGameDialog} > diff --git a/src/views/Game/index.tsx b/src/views/Game/index.tsx index d98242f..1b7e8ed 100644 --- a/src/views/Game/index.tsx +++ b/src/views/Game/index.tsx @@ -24,6 +24,7 @@ const GameView: FunctionComponent = () => { const game = useGame((state) => ({ DrawCard: state.DrawCard, cards: state.draws, + offline: state.offline, })); const settings = useSettings((state) => ({ @@ -216,7 +217,9 @@ const GameView: FunctionComponent = () => { - +