Skip to content
Snippets Groups Projects
Commit 2441714e authored by L4929's avatar L4929
Browse files

Added timing for updating Player component. Also fixed circle and rectangle dragging bug again

parent 77efbaec
No related branches found
No related tags found
2 merge requests!21Development,!20Add tracked players to map
......@@ -252,14 +252,14 @@ class DrawTools extends Component {
onDeleteStop={this._onEditDeleteStop}
draw={{
circle: {
repeatMode: true, // allows using the tool again after finishing the previous shape
repeatMode: false, // allows using the tool again after finishing the previous shape
shapeOptions: {
color: "#f9f10c",
opacity: 1 // affects the outline only. for some reason it wasn't at full opacity, so this is needed for more clarity
}
},
rectangle: {
repeatMode: true
repeatMode: false
},
polygon: {
repeatMode: true,
......
......@@ -5,7 +5,8 @@ class Player extends Component {
constructor(props) {
super(props);
this.state = {
players: null
players: null,
time: Date.now()
};
}
......@@ -33,6 +34,14 @@ class Player extends Component {
});
}
componentDidMount() {
// update components every 10 seconds
this.interval = setInterval(
() => this.setState({ time: Date.now() }),
10000
);
}
shouldComponentUpdate(nextProps, nextState) {
// do not update component until players have been fetched and game ID is available
if (this.state.players === null) {
......@@ -54,6 +63,10 @@ class Player extends Component {
}
}
componentWillUnmount() {
clearInterval(this.interval);
}
render() {
return (
<div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment