-
Notifications
You must be signed in to change notification settings - Fork 4
201 server host reassignment #254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
7432542
249382f
071655c
6485c2e
dab1559
636c577
ad509f1
9430db7
c9dc430
6374d10
7962d61
3f43747
e1667d4
3cee1b5
f3f76ad
a1c5ccc
663ea64
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -4,6 +4,7 @@ import { useNavigate, Navigate } from "react-router-dom"; | |||||||||||||
| import { GameStartedMessage } from "../../common/message/game-message"; | ||||||||||||||
| import { useSocket, useEffectQuery, get } from "../api"; | ||||||||||||||
| import { ClientType } from "../../common/client-types"; | ||||||||||||||
| import { ThemeButtons } from "./setup"; | ||||||||||||||
|
|
||||||||||||||
| /** | ||||||||||||||
| * check for an active game and waits for one or forwards to setup | ||||||||||||||
|
|
@@ -41,10 +42,27 @@ export function Lobby() { | |||||||||||||
| } else { | ||||||||||||||
| return ( | ||||||||||||||
| <SetupBase> | ||||||||||||||
| <NonIdealState | ||||||||||||||
| title="Waiting For Game to Start" | ||||||||||||||
| icon={<Spinner intent="primary" />} | ||||||||||||||
| /> | ||||||||||||||
| <> | ||||||||||||||
| <NonIdealState | ||||||||||||||
| title={ | ||||||||||||||
| data.clientType === ClientType.CLIENT ? | ||||||||||||||
| "Waiting For Host to Start" | ||||||||||||||
| : "Waiting in line" | ||||||||||||||
|
Comment on lines
+48
to
+50
|
||||||||||||||
| data.clientType === ClientType.CLIENT ? | |
| "Waiting For Host to Start" | |
| : "Waiting in line" | |
| data.clientType === ClientType.CLIENT | |
| ? "Waiting For Host to Start" | |
| : "Waiting in line" |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -132,20 +132,7 @@ function SetupMain(props: SetupMainProps) { | |||||||||
| onClick={() => props.onPageChange(SetupType.PUZZLE)} | ||||||||||
| className={buttonColor()} | ||||||||||
| /> | ||||||||||
| <h3 className={textColor()}>Display Settings:</h3> | ||||||||||
| <ButtonGroup variant="outlined"> | ||||||||||
| {allSettings.map((item, idx) => ( | ||||||||||
| <Button | ||||||||||
| key={item[0]} | ||||||||||
| textClassName={textColor()} | ||||||||||
| //changed for better visibility | ||||||||||
| icon={item[1]} | ||||||||||
| text={item[0]} | ||||||||||
| active={getUserSetting() === idx} | ||||||||||
| onClick={() => setUserSetting(idx)} | ||||||||||
| /> | ||||||||||
| ))} | ||||||||||
| </ButtonGroup> | ||||||||||
| <ThemeButtons /> | ||||||||||
| </> | ||||||||||
| ); | ||||||||||
|
|
||||||||||
|
|
@@ -163,8 +150,31 @@ function SetupMain(props: SetupMainProps) { | |||||||||
| }} | ||||||||||
| > | ||||||||||
| <H3 className={textColor()}>Welcome to Chess Bot!</H3> | ||||||||||
|
|
||||||||||
| {actions} | ||||||||||
| </div> | ||||||||||
| </> | ||||||||||
| ); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| export function ThemeButtons(props): JSX.Element { | ||||||||||
| props; | ||||||||||
|
Comment on lines
+160
to
+161
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove props, since we don't use them.
Comment on lines
+160
to
+161
|
||||||||||
| export function ThemeButtons(props): JSX.Element { | |
| props; | |
| export function ThemeButtons(props: Record<string, never>): JSX.Element { | |
| // no props expected |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,106 @@ | ||||||
| import { Button, NonIdealState } from "@blueprintjs/core"; | ||||||
| import type { Dispatch } from "react"; | ||||||
| import { useState } from "react"; | ||||||
| import type { MessageHandler } from "../../common/message/message"; | ||||||
| import { JoinQueue, UpdateQueue } from "../../common/message/game-message"; | ||||||
| import { get, useEffectQuery, useSocket } from "../api"; | ||||||
| import { | ||||||
| bgColor, | ||||||
| buttonColor, | ||||||
| textBoxColor, | ||||||
| textColor, | ||||||
| } from "../check-dark-mode"; | ||||||
|
|
||||||
| function getMessageHandler(setQueue: Dispatch<string[]>): MessageHandler { | ||||||
| return (message) => { | ||||||
| if (message instanceof UpdateQueue) { | ||||||
| setQueue(message.queue.slice()); | ||||||
| } | ||||||
| }; | ||||||
| } | ||||||
|
|
||||||
| interface sidebarProps { | ||||||
| top?: number | undefined; | ||||||
| } | ||||||
|
|
||||||
| /** | ||||||
| * Creates a sidebar to hold the queue elements | ||||||
| * @returns sidebar container | ||||||
| */ | ||||||
| export function Sidebar(props: sidebarProps): JSX.Element { | ||||||
| const [queue, setQueue] = useState<string[]>([]); | ||||||
| const [name, setName] = useState<string>( | ||||||
| "player " + Math.floor(Math.random() * 10000), | ||||||
| ); | ||||||
|
|
||||||
| const sendMessage = useSocket(getMessageHandler(setQueue)); | ||||||
| const { isPending, data, isError } = useEffectQuery( | ||||||
| "get-queue", | ||||||
| async () => { | ||||||
| return get("/get-queue").then((newQueue) => { | ||||||
| setQueue(newQueue); | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I might not be reading this right, but I don't get why we store the queue information twice, once in the |
||||||
| return newQueue; | ||||||
| }); | ||||||
| }, | ||||||
| true, | ||||||
| ); | ||||||
|
|
||||||
| const names = useEffectQuery( | ||||||
| "get-name", | ||||||
| async () => { | ||||||
| return get("/get-name").then((name) => { | ||||||
| if (name.message) setName(name.message); | ||||||
| return name; | ||||||
| }); | ||||||
| }, | ||||||
| true, | ||||||
| ); | ||||||
|
|
||||||
| if (names.isError) { | ||||||
| console.log(names.isError); | ||||||
| } | ||||||
| //ts wanted me to do something with my data | ||||||
| data; | ||||||
|
||||||
| data; | |
| void data; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there any way we can do this with mostly blueprint js components? just for visual consistency
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what this do