Skip to content

Commit 24e9cf5

Browse files
committed
stuff and things
1 parent 87d3ea1 commit 24e9cf5

File tree

17 files changed

+652
-124
lines changed

17 files changed

+652
-124
lines changed
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
index.html,1675915329931,a076fe07b12b12c2fb2b79eacef09fb9e43ab21f23117b59488df468a7ae5afb
2-
assets/media/icon50x50.png,1675915329932,aff83c1b5e8c8b28ef34ff190ffff75676bab05bd66382928e489bbf8e512f9e
3-
manifest.json,1675915329931,a32ca6aea20b60f73fb15ee793737d9fd689148057fa1cccfe0f825939e11a96
4-
assets/media/TwemojiHeart.svg,1675915329932,91a74f778528cb2ab30fdb256916c14ce9527c92765f6acd6c862e66499fdb62
5-
assets/scripts/main.js.LICENSE.txt,1675915329932,d3453a63902997ad204993d0b90fea97bffb4a8cd4934a1696a109a2947e6e0f
6-
assets/styles/main.css,1675915329932,bef67429c264fc55c55eb6ed377b287a20d56724cb57f672bb815c0effb9627d
7-
assets/scripts/main.js,1675915330085,95162d63940302eb328b74e4f2a342cdf8073eb43d4c2e8024f2360f884f556c
8-
assets/media/background.jpg,1675915330157,5a2da1ebe47a86f393c2e0214c2f59bd50d30c72c4ce433a5870ddcfb5773741
1+
index.html,1675922649236,99caa826e394119e0c7748d1834d0652054d4b2b95343ef09b2634be0a1a1476
2+
manifest.json,1675922649236,746e3278ad6f7cfdbfc44002550985585b054824ba08be5ccaa45a53d10e1cf3
3+
assets/media/background.jpg,1675922649430,5a2da1ebe47a86f393c2e0214c2f59bd50d30c72c4ce433a5870ddcfb5773741
4+
assets/media/icon50x50.png,1675922649237,aff83c1b5e8c8b28ef34ff190ffff75676bab05bd66382928e489bbf8e512f9e
5+
assets/media/TwemojiHeart.svg,1675922649238,91a74f778528cb2ab30fdb256916c14ce9527c92765f6acd6c862e66499fdb62
6+
assets/scripts/main.js.LICENSE.txt,1676010633517,e894edd8728ca24421593822ba736ea4225d88f445c8d936ecfd190cc27fc15d
7+
assets/styles/main.css,1676010633517,1f2b38cf9d5be5d4864b74a2ae6b3fc7ce243921fb5bb7ed2df73a17128cafe0
8+
assets/scripts/main.js,1676076407286,9e4967428289b84518ac60d1aedcdb33fe009a7a4fbb2bcc830ce019b9da60bb

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,5 @@ Please note that mobile support is not yet available. I am not responsible for a
77

88
# TODO
99
#### Add a low chance to request a question from a random player
10-
#### Add bots - The bots will allow less than 3 players to play together by auto-filling random gifs as response to each question. Voting for a bot would throw the vote away, making it possible to play with less than 3 players.
1110
#### Add tag guidelines - This will force whatever tag guidelines the host decides to be inserted into every gif search the user does.
1211
#### Add timers

package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,24 @@
1212
"dependencies": {
1313
"firebase": "^9.17.1",
1414
"lodash": "^4.17.21",
15-
"random-username-generator": "^1.0.4",
1615
"react": "^17.0.2",
1716
"react-dom": "^17.0.2",
1817
"react-feather": "^2.0.9",
19-
"regenerator-runtime": "^0.13.9"
18+
"regenerator-runtime": "^0.13.9",
19+
"unique-username-generator": "^1.1.3"
2020
},
2121
"devDependencies": {
2222
"@svgr/webpack": "^5.5.0",
2323
"@swc/cli": "^0.1.51",
2424
"@swc/core": "^1.2.93",
25+
"crypto-browserify": "^3.12.0",
2526
"css-loader": "^6.3.0",
2627
"file-loader": "^6.2.0",
2728
"html-webpack-plugin": "^5.3.2",
2829
"mini-css-extract-plugin": "^2.4.2",
2930
"sass": "^1.42.1",
3031
"sass-loader": "^12.1.0",
32+
"stream-browserify": "^3.0.0",
3133
"style-loader": "^3.3.0",
3234
"swc-loader": "^0.1.15",
3335
"webpack": "^5.58.0",
@@ -37,6 +39,7 @@
3739
},
3840
"scripts": {
3941
"start": "npx webpack serve --open",
40-
"build": "npx webpack --mode production --env=mode=production"
42+
"build": "npx webpack --mode production --env=mode=production",
43+
"publish": "yarn run build && firebase deploy --only hosting"
4144
}
4245
}

src/App.jsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import randomUsernameGenerator from "random-username-generator";
21
import { useState } from "react";
2+
import * as uug from "unique-username-generator";
33
import "./App.scss";
44
import background from "./Assets/background.jpg";
55
import "./city-fog-theme.css";
@@ -51,7 +51,11 @@ if (!localUser) {
5151
TenorClient.random("galaxy space aesthetic wallpaper").then(({ results: [pfp] }) => {
5252
localUser = {
5353
id: getRandomKey(),
54-
username: randomUsernameGenerator.generate(),
54+
username: uug.uniqueUsernameGenerator({
55+
dictionaries: [uug.adjectives, uug.nouns, uug.adjectives, uug.nouns, uug.adjectives, uug.nouns],
56+
separator: "",
57+
style: "capital"
58+
}),
5559
avatar: pfp.media[0].tinygif.url
5660
};
5761

src/Classes/Packs.js

Lines changed: 21 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Classes/Stores/RoomStore.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,18 @@ export const RoomStage = {
1313
FINAL: 3
1414
};
1515

16+
const usedQuestions = [];
1617
export class Room {
1718
id;
1819
hostId;
1920
users = {};
20-
guidelineTag = ""; // TODO add this
21+
gifFilters = "";
2122

2223
packs = Object.keys(questionPacks);
23-
usedQuestions = [];
24+
botCount = 0;
2425

2526
getRandomPlayer() {
26-
const players = Object.values(this.users);
27+
const players = Object.values(this.users).filter(user => !user.bot);
2728

2829
return players[Math.floor(Math.random() * players.length)];
2930
}
@@ -33,11 +34,11 @@ export class Room {
3334
const validQuestions = Object.entries(questionPacks).filter(([key, value]) => this.packs.includes(key)).map(([key, value]) => value).flat();
3435
let question;
3536

36-
while (!question || ~this.usedQuestions.indexOf(question)) {
37+
while (!question || ~usedQuestions.indexOf(question)) {
3738
question = validQuestions[Math.floor(Math.random() * validQuestions.length)];
3839
}
3940

40-
this.usedQuestions.push(question);
41+
usedQuestions.push(question);
4142
return question.replace("XNAME", this.getRandomPlayer().username);
4243
}
4344

@@ -47,7 +48,7 @@ export class Room {
4748

4849
getLastAwaitedPlayer() {
4950
for (const user of Object.values(this.users)) {
50-
if (!this.gifs[user.id]) {
51+
if (!this.gifs[user.id] && !user.bot) {
5152
return user;
5253
}
5354
}
@@ -70,7 +71,7 @@ export class Room {
7071
}
7172

7273
getWinner() {
73-
if (Object.keys(this.votes).length !== Object.keys(this.users).length)
74+
if (Object.keys(this.votes).length !== Object.keys(this.users).length - this.botCount)
7475
return null;
7576

7677
const votes = this.getVoteCounts();

src/Classes/TenorClient.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { getRandomKey } from "./Constants";
1+
import { localUser } from "../App";
22

33
const endpoint = "https://g.tenor.com/v1";
44
const key = "LXAB5RW7WVWA";
55
const defaultProps = {
66
"media_filter": "minimal",
77
"limit": 50,
8-
get "anon_id"() { return getRandomKey(); }
8+
get "anon_id"() { return localUser?.id; }
99
};
1010

1111
let lastFetch = 0;

src/Components/PageElements/GifPicker.jsx

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import _ from "lodash";
22
import { useCallback, useEffect, useState } from "react";
3-
import { ChevronsUp, Grid } from "react-feather";
3+
import { ChevronUp, Grid } from "react-feather";
44
import { getRandomKey, joinClassNames } from "../../Classes/Constants";
5+
import RoomStore from "../../Classes/Stores/RoomStore";
56
import TenorClient from "../../Classes/TenorClient";
67
import Tooltip from "../Tooltip";
78
import "./GifPicker.scss";
@@ -15,29 +16,39 @@ export default function GifPicker() {
1516
const [open, setOpen] = useState(false);
1617
const [pickingCallback, setPickingCallback] = useState(null);
1718

18-
useEffect(() => {
19-
TenorClient.getTrending().then(({ results }) => (setTrending(results), setItems(results)));
19+
const currentRoom = RoomStore.useState(() => RoomStore.getCurrentRoom());
20+
const filters = RoomStore.useState(() => (RoomStore.getCurrentRoom()?.gifFilters ?? "") + " ");
2021

22+
useEffect(() => {
2123
openGifPicker = async function () {
2224
setOpen(true);
2325

24-
2526
return new Promise(async (resolve, reject) => {
2627
setPickingCallback({ resolve, reject });
2728
});
2829
}
2930
}, []);
3031

32+
useEffect(() => {
33+
if (currentRoom && filters.length > 1) {
34+
TenorClient.search(currentRoom.gifFilters).then(({ results }) => (setTrending(results), setItems(results)));
35+
}
36+
else {
37+
TenorClient.getTrending().then(({ results }) => (setTrending(results), setItems(results)));
38+
search("");
39+
}
40+
}, [filters]);
41+
3142
const makeRequest = useCallback(
3243
_.debounce((query, prepend = []) => {
33-
TenorClient.search(query).then(response => {
44+
TenorClient.search((filters + query).trim()).then(response => {
3445
setItems([
3546
...prepend,
3647
...response.results
3748
]);
3849
});
3950
}, 200),
40-
[]
51+
[currentRoom]
4152
);
4253

4354
useEffect(() => {
@@ -66,11 +77,11 @@ export default function GifPicker() {
6677
return (
6778
<div className={joinClassNames("GifPicker", [open, "Open"])}>
6879
<div className="SlideButton FlexCenter" onClick={() => setOpen(!open)}>
69-
<ChevronsUp />
80+
<ChevronUp />
7081
</div>
7182

7283
<div className="SearchBarContainer FlexCenter">
73-
<div className="RandomButton FlexCenter" onClick={() => TenorClient.search(getRandomKey()).then(({ results }) => setItems(results))}>
84+
<div className="RandomButton FlexCenter" onClick={() => TenorClient.search((filters + getRandomKey()).trim()).then(({ results }) => setItems(results))}>
7485
<Grid />
7586

7687
<Tooltip>Random</Tooltip>

src/Components/PageElements/GifPicker.scss

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,33 @@
1717

1818
&:not(.Open) {
1919
transform: translateY(50vh);
20+
21+
.SlideButton > svg {
22+
transform: none;
23+
}
2024
}
2125

2226
.SlideButton {
2327
position: absolute;
2428
left: 15px;
25-
top: -30px;
29+
top: -40px;
30+
padding-bottom: 10px;
2631

2732
width: 40px;
2833
height: 30px;
29-
background: $primaryBG;
34+
background: rgba(white, 0.1);
3035
border-radius: 7px 7px 0 0;
3136
backdrop-filter: blur(20px);
3237

3338
cursor: pointer;
3439

3540
> svg {
41+
margin-top: 12px;
3642
width: 35px;
3743
height: 35px;
44+
45+
transform: rotateZ(-180deg);
46+
transition: transform $t;
3847
}
3948
}
4049

src/Components/Toasts.jsx

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,54 @@
11
import React from "react";
2-
import "./Toasts.scss";
32
import { getRandomKey, joinClassNames } from "../Classes/Constants";
43
import Timer from "../Classes/TimerClass";
4+
import "./Toasts.scss";
55

66
export function Toast({ children, type, life, remove, callback, color, fixedTime = false }) {
77
const handleRemove = () => {
88
setClosing(true);
99

1010
setTimeout(remove, 500);
1111
};
12-
12+
1313
const [closing, setClosing] = React.useState(false);
1414
const timer = React.useMemo(() => new Timer(handleRemove, life * 1000, false), []);
1515
const progressBar = React.useRef();
16-
16+
1717
const handleMouseEnter = () => {
1818
timer.pause();
1919
progressBar.current.style.animationPlayState = "paused";
2020
};
21-
21+
2222
const handleMouseLeave = () => {
2323
timer.resume();
2424
progressBar.current.style.animationPlayState = "running";
2525
};
26-
26+
2727
React.useEffect(() => {
2828
const handleFocus = () => !fixedTime && handleMouseLeave();
2929
const handleBlur = () => !fixedTime && handleMouseEnter();
30-
30+
3131
window.addEventListener("focus", handleFocus);
3232
window.addEventListener("blur", handleBlur);
33-
33+
3434
(fixedTime || document.hasFocus()) && handleMouseLeave();
35-
35+
3636
return () => {
3737
window.removeEventListener("focus", handleFocus);
3838
window.removeEventListener("blur", handleBlur);
3939
};
4040
});
41-
41+
4242
return (
4343
<div className={joinClassNames("Toast", [closing, "Closing"], type)}
44-
onMouseEnter={fixedTime ? null : handleMouseEnter}
45-
onMouseLeave={fixedTime ? null : handleMouseLeave}
46-
onClick={callback ? e => { callback(e); timer.end(); } : () => { timer.end(); }}
47-
style={{ cursor: callback ? "pointer" : null, backgroundColor: color }}>
48-
{ children }
44+
onMouseEnter={fixedTime ? null : handleMouseEnter}
45+
onMouseLeave={fixedTime ? null : handleMouseLeave}
46+
onClick={callback ? e => { callback(e); timer.end(); } : () => { timer.end(); }}
47+
style={{ cursor: callback ? "pointer" : null, backgroundColor: color }}>
48+
{children}
4949

5050
<div className="ProgressBarContainer">
51-
<div ref={progressBar} className="ProgressBar" style={{ animationDuration: life + "s" }}/>
51+
<div ref={progressBar} className="ProgressBar" style={{ animationDuration: life + "s" }} />
5252
</div>
5353
</div>
5454
);
@@ -57,16 +57,16 @@ export function Toast({ children, type, life, remove, callback, color, fixedTime
5757
export default class Toasts extends React.Component {
5858
static instance;
5959
static ref = React.createRef();
60-
60+
6161
state = { toasts: [] };
6262

6363
componentDidMount() {
6464
Toasts.instance = this;
6565
}
66-
66+
6767
static showToast(children, type = "", life = 5, additionalOptions = {}) {
6868
const { callback = null, color = null, fixedTime = false } = additionalOptions;
69-
69+
7070
const toast = React.createElement(Toast, {
7171
key: getRandomKey(),
7272
children, type, life, color, fixedTime,
@@ -76,13 +76,13 @@ export default class Toasts extends React.Component {
7676
callback
7777
});
7878

79-
this.instance.setState({ toasts: [ ...this.instance.state.toasts, toast ] });
79+
this.instance.setState({ toasts: [...this.instance.state.toasts, toast] });
8080
return toast;
8181
}
82-
82+
8383
get horizontalStyle() {
84-
return "Center";
85-
84+
return "Left";
85+
8686
// switch (Settings.props.notifications.toasts.positionX) {
8787
// case 0:
8888
// return "Left";
@@ -92,10 +92,10 @@ export default class Toasts extends React.Component {
9292
// return "Right";
9393
// }
9494
}
95-
95+
9696
get verticalStyle() {
9797
return "Bottom";
98-
98+
9999
// switch (Settings.props.notifications.toasts.positionY) {
100100
// case 0:
101101
// return "Top";
@@ -110,8 +110,8 @@ export default class Toasts extends React.Component {
110110
<div className={joinClassNames("ClearButton", [!!this.state.toasts?.length, "Visible"])} onClick={() => this.setState({ toasts: [] })}>
111111
<u>Close all</u>
112112
</div>
113-
114-
{ this.state.toasts }
113+
114+
{this.state.toasts}
115115
</div>
116116
);
117117
}

0 commit comments

Comments
 (0)