Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
* .validate rules are not called for deletes, so newData.exists() is
  always true in them
* Show cards face down during pause
* Default to all games on the profile page
  • Loading branch information
eltoder committed Feb 3, 2025
1 parent 82c6f7d commit 257f469
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
8 changes: 4 additions & 4 deletions database.rules.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
".validate": "newData.isNumber() && newData.val() == now"
},
"status": {
".write": "auth != null && auth.uid == data.parent().child('host').val() && data.exists() && newData.exists()",
".write": "auth != null && auth.uid == data.parent().child('host').val() && newData.exists()",
".validate": "newData.isString() && (data.val() == 'waiting' && newData.val() == 'ingame')"
},
"users": {
"$userId": {
".write": "auth != null && auth.uid == $userId && data.parent().parent().child('status').val() == 'waiting' && !(root.hasChild('users/' + auth.uid + '/banned') && now < root.child('users/' + auth.uid + '/banned').val())",
".validate": "!newData.exists() || (newData.isNumber() && newData.val() == now)"
".validate": "newData.isNumber() && newData.val() == now"
}
},
"mode": {
Expand Down Expand Up @@ -101,7 +101,7 @@
},
"connections": {
"$connectionId": {
".validate": "newData.isString() || !newData.exists()"
".validate": "newData.isString()"
}
},
"banned": {
Expand All @@ -118,7 +118,7 @@
".indexOn": ".value",
"$gameId": {
".write": "auth != null && auth.uid == $userId",
".validate": "!newData.exists() || (newData.isNumber() && newData.val() == root.child('games/' + $gameId + '/createdAt').val())"
".validate": "newData.isNumber() && newData.val() == root.child('games/' + $gameId + '/createdAt').val()"
}
}
},
Expand Down
10 changes: 3 additions & 7 deletions src/pages/GamePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ const useStyles = makeStyles((theme) => ({
width: "calc(100% - 16px)",
height: "calc(100% - 16px)",
borderRadius: 4,
background: "rgba(0, 0, 0, 0.5)",
transition: "opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms",
zIndex: 2,
justifyContent: "center",
Expand Down Expand Up @@ -367,12 +368,7 @@ function GamePage({ match }) {
{/* Backdrop; active when the game ends or is paused */}
<div
className={classes.doneOverlay}
style={{
display: gameEnded || paused ? "flex" : "none",
background: gameEnded
? "rgba(0, 0, 0, 0.5)"
: "rgba(0, 0, 0, 0.85)",
}}
style={{ display: gameEnded || paused ? "flex" : "none" }}
>
<Paper elevation={3} className={classes.doneModal}>
<Typography variant="h5" gutterBottom>
Expand Down Expand Up @@ -420,7 +416,7 @@ function GamePage({ match }) {
lastSet={lastSet}
answer={hint}
remaining={current.length - board.length}
faceDown={gameMode === "memory"}
faceDown={paused || gameMode === "memory"}
/>
</Grid>
</Box>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/ProfilePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ function ProfilePage({ match }) {
const [stats, loadingStats] = useStats(userId);
const [redirect, setRedirect] = useState(null);
const [variant, setVariant] = useState("all");
const [modeVariant, setModeVariant] = useState("normal");
const [modeVariant, setModeVariant] = useState("all");

const handleClickGame = (gameId) => {
setRedirect(`/room/${gameId}`);
Expand Down

0 comments on commit 257f469

Please sign in to comment.