-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
base: master
Are you sure you want to change the base?
Conversation
Adds a new global variable to store the current board object, and iterates over board array to select the currently active board.
@@ -1,4 +1,4 @@ | |||
import { Chess } from 'chessops/chess'; | |||
public import { Chess } from 'chessops/chess'; |
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.
why is this necessary?
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.
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 |
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.
why do we have both currentSerialnr
and currentBoard.serialnr
?
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.
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.
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.
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.
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.
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.
Adds a new global variable to store the current board object, and iterates over board array to select the currently active board.