diff --git a/frontend/src/features/playScenario/PlayScenarioPage.jsx b/frontend/src/features/playScenario/PlayScenarioPage.jsx
index 5bd1039e..46ceaa7f 100644
--- a/frontend/src/features/playScenario/PlayScenarioPage.jsx
+++ b/frontend/src/features/playScenario/PlayScenarioPage.jsx
@@ -1,6 +1,7 @@
import { useContext, useState, useEffect } from "react";
import { useParams, useHistory } from "react-router-dom";
import axios from "axios";
+import toast from "react-hot-toast";
import AuthenticationContext from "context/AuthenticationContext";
import { usePost } from "hooks/crudHooks";
@@ -51,10 +52,18 @@ export default function PlayScenarioPage() {
const [addFlags, setAddFlags] = useState([]);
const [removeFlags, setRemoveFlags] = useState([]);
+ const reload = () => {
+ setPrevious(null);
+ history.replace(`/play/${scenarioId}/singleplayer`);
+ };
+
const handleError = (error) => {
if (!error) return;
if (error.status === 409) {
- history.push(`/play/${scenarioId}/desync`);
+ reload();
+ toast.success(
+ "A move from somewhere else was made, but you're back on track!"
+ );
} else {
history.push(`/play/${scenarioId}/error`);
}
@@ -93,9 +102,7 @@ export default function PlayScenarioPage() {
return;
}
- console.log("reset");
- setPrevious(null);
- history.replace(`/play/${scenarioId}/singleplayer`);
+ reload();
};
if (loading) return ;
diff --git a/frontend/src/features/playScenario/PlayScenarioPageMulti.jsx b/frontend/src/features/playScenario/PlayScenarioPageMulti.jsx
index bdf2017e..b6380118 100644
--- a/frontend/src/features/playScenario/PlayScenarioPageMulti.jsx
+++ b/frontend/src/features/playScenario/PlayScenarioPageMulti.jsx
@@ -69,10 +69,18 @@ export default function PlayScenarioPageMulti({ group }) {
const [removeFlags, setRemoveFlags] = useState([]);
const [resources, setResources] = useState([]);
+ const reload = () => {
+ setPrevious(null);
+ history.replace(`/play/${scenarioId}/multiplayer`);
+ };
+
const handleError = (error) => {
if (!error) return;
if (error.status === 409) {
- history.push(`/play/${scenarioId}/desync`);
+ reload();
+ toast.success(
+ "Someone else made a move first, but you're back on track!"
+ );
} else if (error.status === 403) {
const roles = JSON.stringify(error.meta.roles_with_access);
history.push(`/play/${scenarioId}/invalid-role?roles=${roles}`);
@@ -115,8 +123,7 @@ export default function PlayScenarioPageMulti({ group }) {
setAddFlags([]);
setRemoveFlags([]);
- setPrevious(null);
- history.replace(`/play/${scenarioId}/multiplayer`);
+ reload();
} catch (error) {
console.error("Error during reset:", error);
}
diff --git a/frontend/src/features/status/DesyncPage.jsx b/frontend/src/features/status/DesyncPage.jsx
deleted file mode 100644
index 1e2c7ad0..00000000
--- a/frontend/src/features/status/DesyncPage.jsx
+++ /dev/null
@@ -1,41 +0,0 @@
-import { Grid, Typography, Button } from "@material-ui/core";
-import { useHistory } from "react-router-dom";
-
-export default function DesyncPage() {
- const history = useHistory();
-
- const onBack = () => {
- history.go(0);
- };
-
- return (
-
-
-
- Desynchronised with server!
-
-
-
- This can happen when someone else made a move while you were
- playing.
-
-
-
- Your last action was not saved.
-
-
-
-
-
-
- );
-}