mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-12-30 03:43:00 +08:00
add quickjoin dev room button
This commit is contained in:
parent
af36597528
commit
8bb1d82e0d
6 changed files with 39 additions and 5 deletions
|
|
@ -74,6 +74,7 @@
|
|||
Coming soon...
|
||||
</span> -->
|
||||
</div>
|
||||
<button class="devRoom">dev room</button>
|
||||
<div class="customRooms">
|
||||
<div class="title">custom rooms</div>
|
||||
<div class="buttons">
|
||||
|
|
|
|||
|
|
@ -104,10 +104,15 @@ addToGlobal({
|
|||
qs: qs,
|
||||
qsa: qsa,
|
||||
qsr: qsr,
|
||||
tribe: Tribe,
|
||||
tribeState: TribeState,
|
||||
tribeCarets: TribeCarets,
|
||||
createTribeRoom: TribeSocket.default.out.room.create,
|
||||
...(isDevEnvironment()
|
||||
? {
|
||||
tribe: Tribe,
|
||||
tribeState: TribeState,
|
||||
tribeCarets: TribeCarets,
|
||||
tribeSocket: TribeSocket.default,
|
||||
}
|
||||
: {}),
|
||||
});
|
||||
|
||||
if (isDevEnvironment()) {
|
||||
|
|
|
|||
|
|
@ -115,6 +115,11 @@ $(".pageTribe .menu .customRooms #createCustomRoom").on("click", (e) => {
|
|||
tribeSocket.out.room.create(Config.mode, mode2);
|
||||
});
|
||||
|
||||
$(".pageTribe .menu .devRoom").on("click", (e) => {
|
||||
if ($(e.currentTarget).hasClass("disabled")) return;
|
||||
tribeSocket.out.dev?.room();
|
||||
});
|
||||
|
||||
$(".pageTribe .menu .matchmaking .buttons .button").on("click", (e) => {
|
||||
if ($(e.currentTarget).hasClass("disabled")) return;
|
||||
const queue = $(e.currentTarget).attr("queue") as string;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
import { isDevEnvironment } from "../../utils/misc";
|
||||
import RoomRoutes from "./routes/room";
|
||||
import SystemRoutes from "./routes/system";
|
||||
import UserRoutes from "./routes/user";
|
||||
import DevRoutes from "./routes/dev";
|
||||
import Socket from "./socket";
|
||||
|
||||
function updateName(newName: string): void {
|
||||
|
|
@ -31,6 +33,11 @@ export default {
|
|||
room: RoomRoutes.out,
|
||||
system: SystemRoutes.out,
|
||||
user: UserRoutes.out,
|
||||
...(isDevEnvironment()
|
||||
? {
|
||||
dev: DevRoutes.out,
|
||||
}
|
||||
: {}),
|
||||
},
|
||||
updateName,
|
||||
connect,
|
||||
|
|
|
|||
7
frontend/src/ts/tribe/tribe-socket/routes/dev.ts
Normal file
7
frontend/src/ts/tribe/tribe-socket/routes/dev.ts
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
import Socket from "../socket";
|
||||
|
||||
export default {
|
||||
out: {
|
||||
room: () => Socket.emit("dev_room"),
|
||||
},
|
||||
};
|
||||
|
|
@ -22,7 +22,7 @@ import * as Random from "../utils/random";
|
|||
import TribeSocket from "./tribe-socket";
|
||||
import * as ActivePage from "../states/active-page";
|
||||
import * as TribeState from "./tribe-state";
|
||||
import { escapeRegExp, escapeHTML } from "../utils/misc";
|
||||
import { escapeRegExp, escapeHTML, isDevEnvironment } from "../utils/misc";
|
||||
import * as Time from "../states/time";
|
||||
import * as TestWords from "../test/test-words";
|
||||
import * as TestStats from "../test/test-stats";
|
||||
|
|
@ -139,6 +139,10 @@ export async function init(): Promise<void> {
|
|||
TribeSocket.updateName(lstribename);
|
||||
}
|
||||
|
||||
if (!isDevEnvironment()) {
|
||||
$(".pageTribe .menu .devRoom").remove();
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
TribeSocket.connect();
|
||||
}, 500);
|
||||
|
|
@ -228,8 +232,13 @@ async function connect(): Promise<void> {
|
|||
if (autoJoinCode !== undefined) {
|
||||
TribePagePreloader.updateText(`Joining room ${autoJoinCode}`);
|
||||
TribePagePreloader.updateSubtext("Please wait...");
|
||||
|
||||
setTimeout(() => {
|
||||
joinRoom(autoJoinCode);
|
||||
if (autoJoinCode === "dev" && isDevEnvironment()) {
|
||||
void TribeSocket.out.dev?.room();
|
||||
} else {
|
||||
joinRoom(autoJoinCode);
|
||||
}
|
||||
}, 500);
|
||||
} else {
|
||||
void TribePages.change("menu");
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue