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
9 changes: 5 additions & 4 deletions src/components/Chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,13 @@ function Chat({
history,
gameMode,
startedAt,
isPlaying = false,
}) {
const user = useContext(UserContext);
const classes = useStyles();
const [stats, loadingStats] = useStats(gameId ? null : user.id);
const [stats, loadingStats] = useStats(isPlaying ? null : user.id);
const chatDisabled =
!gameId && !isDev && (loadingStats || stats.all.all.totalSets < 55);
!isPlaying && !isDev && (loadingStats || stats.all.all.totalSets < 67);

const chatEl = useRef();
useEffect(() => {
Expand Down Expand Up @@ -187,7 +188,7 @@ function Chat({
};

const items = messages;
if (gameId && history) {
if (history) {
for (let i = 0; i < history.length; i++) {
items[`card@${i}`] = history[i];
}
Expand Down Expand Up @@ -290,7 +291,7 @@ function Chat({
arrow
title={
chatDisabled
? "New users cannot chat. Play a couple games first!"
? "New users can only chat when playing. Play a couple games first!"
: ""
}
>
Expand Down
10 changes: 4 additions & 6 deletions src/pages/GamePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,9 @@ function GamePage({ match }) {

const [game, loadingGame] = useFirebaseRef(`games/${gameId}`);
const [gameData, loadingGameData] = useFirebaseRef(`gameData/${gameId}`);
const spectating = !(game?.users && user.id in game.users);
const [hasNextGame] = useFirebaseRef(
game?.status === "done" && (!game.users || !(user.id in game.users))
? `games/${nextGameId}/status`
: null
spectating && game?.status === "done" ? `games/${nextGameId}/status` : null
);
const [playSuccess] = useSound(foundSfx);
const [playFail1] = useSound(failSfx1);
Expand Down Expand Up @@ -241,7 +240,6 @@ function GamePage({ match }) {

const numHints = gameData.hints ?? 0;
const paused = gameData.pause?.start && !gameData.pause.end;
const spectating = !game.users || !(user.id in game.users);
const leaderboard = Object.keys(game.users).sort(
(u1, u2) =>
(scores[u2] || 0) - (scores[u1] || 0) ||
Expand All @@ -268,8 +266,7 @@ function GamePage({ match }) {
const gameEnded = !answer || game.status === "done";
if (
!answer &&
game.users &&
user.id in game.users &&
!spectating &&
game.status === "ingame" &&
finished.gameId !== gameId
) {
Expand Down Expand Up @@ -424,6 +421,7 @@ function GamePage({ match }) {
history={history}
startedAt={game.startedAt}
gameMode={gameMode}
isPlaying={!spectating}
/>
</Paper>
)}
Expand Down
1 change: 1 addition & 0 deletions src/pages/RoomPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ function RoomPage({ match, location }) {
title="Game Chat"
messageLimit={200}
gameId={gameId}
isPlaying={true}
showMessageTimes
/>
</Paper>
Expand Down