diff --git a/src/Mine/SeekerBundle/Resources/public/js/mine-seeker/grid/grid-control.js b/src/Mine/SeekerBundle/Resources/public/js/mine-seeker/grid/grid-control.js
index 4b99f57..448dd10 100644
--- a/src/Mine/SeekerBundle/Resources/public/js/mine-seeker/grid/grid-control.js
+++ b/src/Mine/SeekerBundle/Resources/public/js/mine-seeker/grid/grid-control.js
@@ -11,7 +11,7 @@ class GridControl extends React.Component {
this.state = {
grid: grid.state.grid,
- updated: [],
+ updatedFieldCache: [],
lastClicked: {
red: null,
blue: null
@@ -38,27 +38,21 @@ class GridControl extends React.Component {
});
/**
- * TODO ez azért kell, mert amíg nem fut le a showAppropriateFields(), addig nem updatelődik a GridField.state
+ * It must be cached because the GridField.state not updated until
+ * all showAppropriateFields() method runned out!!
*/
- if (
- this.state.grid[row][col] !== 0 &&
- this.state.updated.indexOf(this.refString(row, col)) < 0 && !currentField.state.active
- ) {
- this.state.updated.push(this.refString(row, col));
- }
+ if (this.state.updatedFieldCache.indexOf(this.refString(row, col)) < 0 && !currentField.state.active) {
+ this.state.updatedFieldCache.push(this.refString(row, col));
- if (
- this.state.grid[row][col] === 0 &&
- this.state.updated.indexOf(this.refString(row, col)) < 0 && !currentField.state.active
- ) {
- this.state.updated.push(this.refString(row, col));
-
- return {
- row: row,
- col: col
- };
+ if (this.state.grid[row][col] === 0) {
+ return {
+ row: row,
+ col: col
+ };
+ }
}
}
+
return false;
}
@@ -83,8 +77,8 @@ class GridControl extends React.Component {
active: true
});
- if (this.state.updated.indexOf(this.refString(row, col)) < 0) {
- this.state.updated.push(this.refString(row, col));
+ if (this.state.updatedFieldCache.indexOf(this.refString(row, col)) < 0) {
+ this.state.updatedFieldCache.push(this.refString(row, col));
}
if (this.state.grid[row][col] === 0) {
@@ -167,7 +161,7 @@ class GridControl extends React.Component {
this.handleGridField(this.state.grid[coords[0]][coords[1]], coords[0], coords[1]);
}
- renderGrid() {
+ renderGridFields() {
var grid = [];
for (var i = 0, j = this.state.grid.length; i < j; i++) {
@@ -193,7 +187,7 @@ class GridControl extends React.Component {
-
-
+
+ {this.currentLastClicked()}