|
@@ -5,7 +5,12 @@ import GuessPane from "./GuessPane";
|
|
import PositionedStreetView from "./PositionedStreetView";
|
|
import PositionedStreetView from "./PositionedStreetView";
|
|
import useRoundInfo from "../../../hooks/useRoundInfo";
|
|
import useRoundInfo from "../../../hooks/useRoundInfo";
|
|
import { dispatch } from '../../../domain/gameStore';
|
|
import { dispatch } from '../../../domain/gameStore';
|
|
-import { useTimerFromLocalStorage, clearTimerFromLocalStorage } from '../../../domain/localStorageMethods';
|
|
|
|
|
|
+import {
|
|
|
|
+ useTimerFromLocalStorage,
|
|
|
|
+ clearTimerFromLocalStorage,
|
|
|
|
+ clearPointFromLocalStorage,
|
|
|
|
+ usePointFromLocalStorage
|
|
|
|
+} from '../../../domain/localStorageMethods';
|
|
import usePreventNavigation from '../../../hooks/usePreventNavigation';
|
|
import usePreventNavigation from '../../../hooks/usePreventNavigation';
|
|
|
|
|
|
const Container = styled.div`
|
|
const Container = styled.div`
|
|
@@ -34,7 +39,7 @@ const StreetViewWrapper = styled.div`
|
|
export default () => {
|
|
export default () => {
|
|
// warn the user if they navigate away
|
|
// warn the user if they navigate away
|
|
usePreventNavigation();
|
|
usePreventNavigation();
|
|
-
|
|
|
|
|
|
+
|
|
const [submitDisabled, setSubmitDisabled] = useState(false);
|
|
const [submitDisabled, setSubmitDisabled] = useState(false);
|
|
const [selectedPoint, setSelectedPoint] = useState(null);
|
|
const [selectedPoint, setSelectedPoint] = useState(null);
|
|
const [finished, roundInfo] = useRoundInfo();
|
|
const [finished, roundInfo] = useRoundInfo();
|
|
@@ -50,17 +55,19 @@ export default () => {
|
|
}
|
|
}
|
|
|
|
|
|
const storedTimer = useTimerFromLocalStorage();
|
|
const storedTimer = useTimerFromLocalStorage();
|
|
|
|
+ const storedPoint = usePointFromLocalStorage();
|
|
|
|
|
|
const handleSubmitGuess = async () => {
|
|
const handleSubmitGuess = async () => {
|
|
setSubmitDisabled(true);
|
|
setSubmitDisabled(true);
|
|
await dispatch.submitGuess(selectedPoint, currentRound, targetPoint);
|
|
await dispatch.submitGuess(selectedPoint, currentRound, targetPoint);
|
|
clearTimerFromLocalStorage();
|
|
clearTimerFromLocalStorage();
|
|
|
|
+ clearPointFromLocalStorage();
|
|
}
|
|
}
|
|
|
|
|
|
return (
|
|
return (
|
|
<Container>
|
|
<Container>
|
|
<StreetViewWrapper>
|
|
<StreetViewWrapper>
|
|
- <PositionedStreetView position={targetPoint} />
|
|
|
|
|
|
+ <PositionedStreetView position={storedPoint ?? targetPoint} resetPosition={targetPoint} />
|
|
</StreetViewWrapper>
|
|
</StreetViewWrapper>
|
|
<GuessPane
|
|
<GuessPane
|
|
roundSeconds={storedTimer ?? roundSeconds}
|
|
roundSeconds={storedTimer ?? roundSeconds}
|