Skip to content

Commit

Permalink
ensure publish
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucieo committed May 6, 2020
1 parent 9b6f369 commit 226a8c5
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 30 deletions.
7 changes: 3 additions & 4 deletions src/components/Counter/applyCountdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@ const applyCountdown = (WrappedComponent) => {
const HOC = (props) => {
const { gameId } = useParams();
const [finished, setFinished] = useState(false);
const [submit, setSubmit] = useState(false);

const timeToSubmit = useSubscription(TIME_TO_SUBMIT, {
variables: { gameId },
onSubscriptionData: ({ client, subscriptionData }) => {
console.log("TIME TO SUBMIT");
setSubmit(true);
setFinished(true);
},
});

Expand All @@ -36,7 +35,7 @@ const applyCountdown = (WrappedComponent) => {
}, []);

const renderCounter = () => {
return !finished && !submit ? (
return !finished ? (
<Countdown
setTime={props.setTime}
submiter={() => setFinished(true)}
Expand All @@ -50,7 +49,7 @@ const applyCountdown = (WrappedComponent) => {
<div className="center" id="CountDown">
{renderCounter()}
</div>
<WrappedComponent {...props} finished={submit} />
<WrappedComponent {...props} finished={finished} />
</>
);
};
Expand Down
46 changes: 23 additions & 23 deletions src/components/GameControls/PlayerControls.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";
import React, { useState } from "react";

export default function PlayerControls({
joinGame,
Expand All @@ -7,30 +7,30 @@ export default function PlayerControls({
loading,
leaveGame,
}) {
const [blocked, setBlocked] = useState(false);
const displayMessage = () => {
if (!hasJoined) {
if (!loading) {
return (
<div className="center">
<p>
Vous avez été invité à jouer à une partie de
esquissé, cliquez sur le bouton ci dessous pour
rejoindre les participants :
</p>
<button
onClick={() => joinGame()}
className={`btn ${loading && "disabled"}`}
>
{loading && (
<i className="material-icons">access_time</i>
)}
REJOINDRE LA PARTIE
</button>
</div>
);
} else {
return <p>Connexion en cours</p>;
}
return (
<div className="center">
<p>
Vous avez été invité à jouer à une partie de esquissé,
cliquez sur le bouton ci dessous pour rejoindre les
participants :
</p>
<button
onClick={() => {
setBlocked(true);
joinGame();
}}
className={`btn ${(loading || blocked) && "disabled"}`}
>
{(loading || blocked) && (
<i className="material-icons">access_time</i>
)}
REJOINDRE LA PARTIE
</button>
</div>
);
} else {
if (players.length < 3) {
return (
Expand Down
5 changes: 5 additions & 0 deletions src/components/GameModes/DrawingMode/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ const DrawingMode = ({ lastPage, finished, pageId }) => {

useEffect(() => {
if (finished) {
console.log("THIS IS THE END SUBMIT NOW");
submitPage();
setTimeout(function () {
console.log("SUBMITTING AGAIN CAPORAL!");
submitPage();
}, 2000);
}
}, [finished]);

Expand Down
5 changes: 5 additions & 0 deletions src/components/GameModes/GuessingMode/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ const GuessingPanel = ({ lastPage, finished, pageId }) => {

useEffect(() => {
if (finished) {
console.log("THIS IS THE END SUBMIT NOW");
submitPage();
setTimeout(function () {
console.log("SUBMITTING AGAIN CAPORAL!");
submitPage();
}, 2000);
}
}, [finished]);

Expand Down
1 change: 0 additions & 1 deletion src/components/GameModes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export default function GameMode({ pages, turn, isGameMaster, setTime }) {
};

const lastPage = getLastPage(currentPage, currentPageIndex);
console.log(isGameMaster, "isGameMaster");
const gameProps = {
turn,
isGameMaster,
Expand Down
2 changes: 1 addition & 1 deletion src/components/PdfFormat/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default function PdfFormat() {
<div className="pdf-format center container">
<h4>Une si belle partie!</h4>
<h5>
avec la participation de{" "}
avec la participation de
{data &&
data.getAllSketchbooks.map((sketchbook, index) => (
<span key={index}> {sketchbook.creator?.name} </span>
Expand Down
13 changes: 13 additions & 0 deletions src/components/StopGame/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,25 @@ export default function StopGame({ isGameMaster }) {
console.log("ending game done");
},
});

//5 seconds to wait before receiving update game call with new turn
const getTimer = () => {
const timer = new Date();
timer.setSeconds(timer.getSeconds() + 5);
return timer;
};

useEffect(() => {
//in case update called has not been received reload in 8 seconds
const reloadInCase = setTimeout(() => {
window.location.reload();
}, 8000);
return function cleanup() {
console.log("CLEANING TIMEOUT");
clearTimeout(reloadInCase);
};
});

const setTime = getTimer();
return (
<div className="stopGame">
Expand Down
1 change: 0 additions & 1 deletion src/layouts/ConnectedPages/Game/ActiveGame.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ const ActiveGame = ({ gameInfo, userId }) => {
});

if (loading) return <Loading />;
console.log("isGameMaster", userId === gameInfo.creator);

return (
<div className="active-game">
Expand Down

0 comments on commit 226a8c5

Please sign in to comment.