Skip to content

Commit 61884d8

Browse files
committed
Minor cleanup
1 parent afa76e2 commit 61884d8

File tree

4 files changed

+24
-26
lines changed

4 files changed

+24
-26
lines changed

src/components/Chat.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,16 @@ function Chat({
124124
const databasePath = gameId ? `chats/${gameId}` : "lobbyChat";
125125
const messagesQuery = useMemo(
126126
() =>
127-
firebase
128-
.database()
129-
.ref(databasePath)
130-
.orderByChild("time")
131-
.limitToLast(messageLimit),
132-
[databasePath, messageLimit]
127+
isHidden
128+
? null
129+
: firebase
130+
.database()
131+
.ref(databasePath)
132+
.orderByChild("time")
133+
.limitToLast(messageLimit),
134+
[isHidden, databasePath, messageLimit]
133135
);
134-
const messages = useFirebaseQuery(isHidden ? null : messagesQuery);
136+
const messages = useFirebaseQuery(messagesQuery);
135137
const mentionRE = useMemo(() => makeMentionRE(user.name), [user.name]);
136138

137139
function handleSubmit(event) {

src/components/ProfileGamesTable.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ function ProfileGamesTable({ userId, gamesData, handleClickGame }) {
6464
if (Object.keys(gamesData).length === 0) {
6565
return (
6666
<Typography style={{ color: grey[400] }}>
67-
No recent games to display...
67+
No recent games in this category.
6868
</Typography>
6969
);
7070
}

src/pages/LobbyPage.js

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -120,22 +120,21 @@ function LobbyPage() {
120120
const [gameMode] = useStorage("gameMode", "normal");
121121
const [practiceMode] = useStorage("practiceMode", "off");
122122

123-
const gamesQuery = useMemo(() => {
124-
return firebase
125-
.database()
126-
.ref("publicGames")
127-
.orderByValue()
128-
.limitToLast(35);
129-
}, []);
123+
const gamesQuery = useMemo(
124+
() => firebase.database().ref("publicGames").orderByValue().limitToLast(35),
125+
[]
126+
);
130127
const games = useFirebaseQuery(gamesQuery);
131128

132-
const myGamesQuery = useMemo(() => {
133-
return firebase
134-
.database()
135-
.ref(`/userGames/${user.id}`)
136-
.orderByValue()
137-
.limitToLast(35);
138-
}, [user.id]);
129+
const myGamesQuery = useMemo(
130+
() =>
131+
firebase
132+
.database()
133+
.ref(`/userGames/${user.id}`)
134+
.orderByValue()
135+
.limitToLast(35),
136+
[user.id]
137+
);
139138
const myGames = useFirebaseQuery(myGamesQuery);
140139

141140
const [stats, loadingStats] = useFirebaseRef("stats");

src/pages/ProfilePage.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ function ProfilePage({ match }) {
8181
.database()
8282
.ref(`/userGames/${userId}`)
8383
.orderByValue()
84-
.limitToLast(64);
84+
.limitToLast(100);
8585
const update = (snapshot) => {
8686
query.off("value", update);
8787
setGames(snapshot.val() ?? {});
@@ -114,9 +114,6 @@ function ProfilePage({ match }) {
114114
if (redirect) {
115115
return <Redirect push to={redirect} />;
116116
}
117-
if (!gameIds) {
118-
return <LoadingPage />;
119-
}
120117

121118
let gamesData = null;
122119
if (!loadingGameVals && !loadingGameDataVals) {

0 commit comments

Comments
 (0)