Commit d2191ee2 authored by Yannick Li's avatar Yannick Li
Browse files

Modify switchConnection

In switchConnection: the transaction must be passed as callback to setState because setState is asynchrounous.
parent e78de4ba
Pipeline #269141 failed with stage
...@@ -143,7 +143,7 @@ class Game extends React.Component<Record<string, unknown>, IGameState> { ...@@ -143,7 +143,7 @@ class Game extends React.Component<Record<string, unknown>, IGameState> {
* This function is used to simulate the offline mode. * This function is used to simulate the offline mode.
*/ */
switchConnection(): void { switchConnection(): void {
this.setState({ isConnected: !this.state.isConnected }); this.setState({ isConnected: !this.state.isConnected }, () => {
if (this.state.isConnected) { if (this.state.isConnected) {
session.transaction(client.utils.ConsistencyLevel.None, () => { session.transaction(client.utils.ConsistencyLevel.None, () => {
for (let index = 0; index < 81; index++) { for (let index = 0; index < 81; index++) {
...@@ -160,6 +160,7 @@ class Game extends React.Component<Record<string, unknown>, IGameState> { ...@@ -160,6 +160,7 @@ class Game extends React.Component<Record<string, unknown>, IGameState> {
clearInterval(this.timeoutGet); clearInterval(this.timeoutGet);
this.modifiedCells = new Array(81).fill(null); this.modifiedCells = new Array(81).fill(null);
} }
});
} }
/** /**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment