Commit ecce80c6 authored by Ludovic Le Frioux's avatar Ludovic Le Frioux
Browse files

Merge branch '24-use-the-new-pull-method' into 'dev'

Resolve "Use the new pull method"

See merge request !22
parents 79d42d07 56445848
Pipeline #249657 canceled with stages
......@@ -7,10 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [Unreleased]
- Added
- Add README file in the top-level repository
- Changed
- Update specific README
- Deprecated
- Removed
- Fixed
- Fix concurrency between edits and remote updates
- Security
This diff is collapsed.
......@@ -6,23 +6,22 @@
"license": "MIT",
"homepage": "./",
"dependencies": {
"@concordant/c-client": "^1.0.0",
"@concordant/c-crdtlib": "^1.0.2",
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
"@types/jest": "^26.0.15",
"@types/node": "^12.0.0",
"@concordant/c-client": "~1.2.0",
"@testing-library/jest-dom": "^5.12.0",
"@testing-library/react": "^11.2.7",
"@testing-library/user-event": "^13.1.9",
"@types/jest": "^26.0.23",
"@types/node": "^14.14.45",
"@types/react": "^16.9.53",
"@types/react-dom": "^16.9.8",
"@types/react-helmet": "^6.1.0",
"@types/react-helmet": "^6.1.1",
"assert": "^2.0.0",
"react": "^16.14.0",
"react-dom": "^16.14.0",
"react-helmet": "^6.1.0",
"react-scripts": "^4.0.3",
"typescript": "^4.0.3",
"web-vitals": "^0.2.4"
"typescript": "^4.2.4",
"web-vitals": "^1.1.2"
},
"scripts": {
"start": "react-scripts start",
......@@ -46,15 +45,15 @@
]
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^4.22.0",
"@typescript-eslint/parser": "^4.22.0",
"@typescript-eslint/eslint-plugin": "^4.23.0",
"@typescript-eslint/parser": "^4.23.0",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.5",
"eslint": "^7.24.0",
"eslint": "^7.26.0",
"eslint-plugin-react": "^7.23.2",
"prettier": "2.2.1",
"husky": "^6.0.0",
"lint-staged": "^10.5.4"
"lint-staged": "^10.5.4",
"prettier": "2.2.1"
},
"lint-staged": {
"*.{js,ts,tsx}": "eslint --cache --fix",
......
......@@ -79,13 +79,23 @@ class Game extends React.Component<Record<string, unknown>, IGameState> {
};
}
/**
* Every 3 seconds, retrieves remote changes
*/
private setSyncTimer() {
this.timerID = setTimeout(() => {
this.pullGrid();
this.setSyncTimer();
}, 3000);
}
/**
* Called after the component is rendered.
* It set a timer to refresh cells values.
*/
componentDidMount(): void {
this.initFrom(generateStaticGrid(this.state.gridNum));
this.timerID = setInterval(() => this.updateGrid(), 1000);
this.setSyncTimer();
}
/**
......@@ -99,12 +109,13 @@ class Game extends React.Component<Record<string, unknown>, IGameState> {
/**
* Update cells values from C-Client.
*/
updateGrid(): void {
const cells = this.state.cells;
pullGrid(): void {
if (!this.state.isConnected) {
console.error("updateGrid() called while not connected.");
return;
}
const cells = this.state.cells;
collection.pull(client.utils.ConsistencyLevel.None);
for (let index = 0; index < 81; index++) {
if (cells[index].modifiable) {
cells[index].value = "";
......@@ -138,7 +149,7 @@ class Game extends React.Component<Record<string, unknown>, IGameState> {
});
}
}
this.timerID = setInterval(() => this.updateGrid(), 1000);
this.setSyncTimer();
}
this.setState({ isConnected: !this.state.isConnected });
}
......
This diff is collapsed.
......@@ -6,21 +6,21 @@
"license": "MIT",
"homepage": "./",
"dependencies": {
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
"@types/jest": "^26.0.15",
"@types/node": "^12.0.0",
"@testing-library/jest-dom": "^5.12.0",
"@testing-library/react": "^11.2.6",
"@testing-library/user-event": "^13.1.8",
"@types/jest": "^26.0.23",
"@types/node": "^14.14.44",
"@types/react": "^16.9.53",
"@types/react-dom": "^16.9.8",
"@types/react-helmet": "^6.1.0",
"@types/react-helmet": "^6.1.1",
"assert": "^2.0.0",
"react": "^16.14.0",
"react-dom": "^16.14.0",
"react-helmet": "^6.1.0",
"react-scripts": "^4.0.3",
"typescript": "^4.0.3",
"web-vitals": "^0.2.4"
"typescript": "^4.2.4",
"web-vitals": "^1.1.2"
},
"scripts": {
"start": "react-scripts start",
......@@ -44,11 +44,11 @@
]
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^4.22.0",
"@typescript-eslint/parser": "^4.22.0",
"@typescript-eslint/eslint-plugin": "^4.22.1",
"@typescript-eslint/parser": "^4.22.1",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.5",
"eslint": "^7.24.0",
"eslint": "^7.25.0",
"eslint-plugin-react": "^7.23.2",
"husky": "^6.0.0",
"lint-staged": "^10.5.4",
......
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