Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ function App() {
);
const [volume, setVolume] = useStorage("volume", "on");
const [notifications, setNotifications] = useStorage("notifications", "on");
const [focusMode, setFocusMode] = useStorage("focusMode", "off");

useEffect(() => {
return firebase.auth().onAuthStateChanged((user) => {
Expand Down Expand Up @@ -162,6 +163,8 @@ function App() {
setVolume,
notifications,
setNotifications,
focusMode,
setFocusMode,
layoutOrientation,
setLayoutOrientation,
cardOrientation,
Expand Down
12 changes: 12 additions & 0 deletions src/components/Navbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ function Navbar() {
);
}

function handleChangeFocusMode() {
settings.setFocusMode((focusMode) => (focusMode === "on" ? "off" : "on"));
}

useKeydown((event) => {
if (getModifierState(event) === "Control") {
if (event.key === "s") {
Expand Down Expand Up @@ -221,6 +225,14 @@ function Navbar() {
{settings.notifications === "on" ? "Disable" : "Enable"}{" "}
notifications
</MenuItem>
<MenuItem
onClick={() => {
handleChangeFocusMode();
handleCloseMenu();
}}
>
{settings.focusMode === "on" ? "Disable" : "Enable"} focus mode
</MenuItem>
<MenuItem
onClick={() => {
handleChangeTheme();
Expand Down
56 changes: 30 additions & 26 deletions src/pages/GamePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ function ensureConnected() {

function GamePage({ match }) {
const user = useContext(UserContext);
const { volume, notifications } = useContext(SettingsContext);
const { volume, notifications, focusMode } = useContext(SettingsContext);
const gameId = match.params.id;
const nextGameId = useMemo(() => getNextGameId(gameId), [gameId]);
const classes = useStyles();
Expand Down Expand Up @@ -432,16 +432,18 @@ function GamePage({ match }) {
<Grid container spacing={2}>
<Box clone order={{ xs: 3, sm: 1 }}>
<Grid item xs={12} sm={4} md={3} className={classes.sideColumn}>
<Paper style={{ display: "flex", height: "100%", padding: 8 }}>
<Chat
title="Game Chat"
messageLimit={200}
gameId={gameId}
history={history}
startedAt={game.startedAt}
gameMode={gameMode}
/>
</Paper>
{(focusMode !== "on" || gameEnded) && (
<Paper style={{ display: "flex", height: "100%", padding: 8 }}>
<Chat
title="Game Chat"
messageLimit={200}
gameId={gameId}
history={history}
startedAt={game.startedAt}
gameMode={gameMode}
/>
</Paper>
)}
</Grid>
</Box>
<Box clone order={{ xs: 1, sm: 2 }} position="relative">
Expand Down Expand Up @@ -510,21 +512,23 @@ function GamePage({ match }) {
</Box>
<Box clone order={{ xs: 2, sm: 3 }}>
<Grid item xs={12} md={3} className={classes.sideColumn}>
<Box order={{ xs: 2, md: 1 }} style={{ maxHeight: "100%" }}>
<GameSidebar
game={game}
scores={scores}
leaderboard={leaderboard}
pause={gameData.pause}
endedAt={
game.status === "done"
? game.endedAt
: !answer && history.length > 0
? history[history.length - 1].time
: 0
}
/>
</Box>
{(focusMode !== "on" || gameEnded) && (
<Box order={{ xs: 2, md: 1 }} style={{ maxHeight: "100%" }}>
<GameSidebar
game={game}
scores={scores}
leaderboard={leaderboard}
pause={gameData.pause}
endedAt={
game.status === "done"
? game.endedAt
: !answer && history.length > 0
? history[history.length - 1].time
: 0
}
/>
</Box>
)}
{game.enableHint && (
<Box order={{ xs: 1, md: 2 }}>
<Box mt={{ xs: 0, md: 2 }} mb={1}>
Expand Down