diff --git a/collaborative/src/components/Game.tsx b/collaborative/src/components/Game.tsx index ce98b75cd3271ad6db96f84a57050bd056ad3e9a..e60544be5401b40129450a98e29a8200a9a9430c 100644 --- a/collaborative/src/components/Game.tsx +++ b/collaborative/src/components/Game.tsx @@ -145,17 +145,17 @@ class Game extends React.Component<Record<string, unknown>, IGameState> { switchConnection(): void { this.setState({ isConnected: !this.state.isConnected }); if (this.state.isConnected) { - for (let index = 0; index < 81; index++) { - if ( - this.state.cells[index].modifiable && - this.modifiedCells[index] !== null - ) { - session.transaction(client.utils.ConsistencyLevel.None, () => { + session.transaction(client.utils.ConsistencyLevel.None, () => { + for (let index = 0; index < 81; index++) { + if ( + this.state.cells[index].modifiable && + this.modifiedCells[index] !== null + ) { this.state.mvmap.setString(index, this.modifiedCells[index]); - }); + } } - } - this.setGetTimeout(); + }); + this.pullGrid(); } else { clearInterval(this.timeoutGet); this.modifiedCells = new Array(81).fill(null); @@ -181,18 +181,18 @@ class Game extends React.Component<Record<string, unknown>, IGameState> { */ reset(): void { const cells = this.state.cells; - for (let index = 0; index < 81; index++) { - if (cells[index].modifiable) { - cells[index].value = ""; - if (this.state.isConnected) { - session.transaction(client.utils.ConsistencyLevel.None, () => { + session.transaction(client.utils.ConsistencyLevel.None, () => { + for (let index = 0; index < 81; index++) { + if (cells[index].modifiable) { + cells[index].value = ""; + if (this.state.isConnected) { this.state.mvmap.setString(index, cells[index].value); - }); - } else { - this.modifiedCells[index] = ""; + } else { + this.modifiedCells[index] = ""; + } } } - } + }); this.setState({ cells: cells }); }