Skip to content

Commit

Permalink
Add a button to reset user's color (#37)
Browse files Browse the repository at this point in the history
Because changing color is a free feature now.
  • Loading branch information
eltoder authored Nov 26, 2024
1 parent f1e5e0a commit 5ec9367
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/components/ProfileName.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import firebase from "../firebase";
import ElapsedTime from "./ElapsedTime";
import User from "./User";
import { UserContext } from "../context";
import { generateName } from "../util";
import { generateColor, generateName } from "../util";

const useStyles = makeStyles((theme) => ({
vertIcon: {
Expand Down Expand Up @@ -45,6 +45,11 @@ function ProfileName({ userId }) {
handleClose();
};

const handleColor = () => {
firebase.database().ref(`users/${userId}/color`).set(generateColor());
handleClose();
};

const handleBan = (minutes) => {
const endTime = Date.now() + minutes * 60000;
firebase.database().ref(`users/${userId}/banned`).set(endTime);
Expand Down Expand Up @@ -88,6 +93,7 @@ function ProfileName({ userId }) {
onClose={handleClose}
>
<MenuItem onClick={handleResetName}>Reset username</MenuItem>
<MenuItem onClick={handleColor}>Reset color</MenuItem>
{player.banned && Date.now() < player.banned ? (
<MenuItem onClick={() => handleUnban()}>Unban</MenuItem>
) : (
Expand Down

0 comments on commit 5ec9367

Please sign in to comment.