Skip to content
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

Adds selection of currently active board in play.ts #10594

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

TheMachineHerald
Copy link

Adds a new global variable to store the current board object, and iterates over board array to select the currently active board.

Adds a new global variable to store the current board object, and iterates over board array to select the currently active board.
ui/dgt/src/play.ts Outdated Show resolved Hide resolved
@@ -1,4 +1,4 @@
import { Chess } from 'chessops/chess';
public import { Chess } from 'chessops/chess';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this necessary?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll take this out. Must've accidentally added this.

@@ -96,6 +96,7 @@ export default function (token: string) {
let liveChessConnection: WebSocket; //Connection Object to LiveChess through websocket
let isLiveChessConnected = false; //Used to track if a board there is a connection to DGT Live Chess
let currentSerialnr = '0'; //Public property to store the current serial number of the DGT Board in case there is more than one
let currentBoard: { serialnr: string; state: string }; //Stores active board object
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we have both currentSerialnr and currentBoard.serialnr?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

currentSerialnr is used in the DGTliveChessConnectionLoop that checks whether it's been assigned a non-null value to determine connection status to the board and in the socket connection's onclose to reset the value back to 0. In line 859 there's a conditional checking a hard coded values from the first boards array index value.

It seems like the code was initially designed to use both a variable to hold the serial number and then it also checks hardcoded array values(assuming the user only has one board) in the code.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this was mostly a rhetorical question. Is there a reason why we need to have both? Because otherwise, it should be changed so that only one value is used everywhere.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it. I'll change it. I was also thinking about making this work with the regular interface so you don't need two tabs open to use this feature.

Sorry for the time between responses, I've been busy with work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants