Skip to content
Snippets Groups Projects
Commit 4bd085ec authored by L4929's avatar L4929
Browse files

Can add, edit and delete drawings without issue and they show up in other...

Can add, edit and delete drawings without issue and they show up in other browser. Also fixed the bug where deleting or editing one element didn't register to the drawer.
parent b6fe70de
No related branches found
No related tags found
2 merge requests!31Development,!27Socket update
......@@ -18,10 +18,6 @@ class App extends Component {
currentGameId: null,
socketSignal: null
};
this.handleLayerChange = this.handleLayerChange.bind(this);
this.handleGameChange = this.handleGameChange.bind(this);
this.getSocketSignal = this.getSocketSignal.bind(this);
}
// Toggles through the list and changes the mapUrl state
handleLayerChange = () => {
......@@ -45,6 +41,8 @@ class App extends Component {
});
};
// setting the socket signal automatically fires shouldComponentUpdate function where socketSignal prop is present
// setting socketSignal to null immediately after to avoid multiple database fetches
getSocketSignal = type => {
this.setState(
{
......
......@@ -25,7 +25,8 @@ export default class ClientSocket extends React.Component {
}
shouldComponentUpdate(nextProps, nextState) {
if (nextProps !== this.props) {
// re-initialize socket when gameId has changed
if (nextProps.gameId !== this.props.gameId) {
this.initSocket();
return true;
} else {
......@@ -46,7 +47,7 @@ export default class ClientSocket extends React.Component {
socket.on(this.props.gameId, data => {
this.props.getSocketSignal(data.type);
// check socket update type
this.setState({ update: data });
this.setState({ update: data.type });
});
this.setState({ sock: socket });
......
......@@ -2,7 +2,6 @@ import React, { Component } from "react";
import { Map, TileLayer, ZoomControl, Marker, Popup } from "react-leaflet";
import DrawTools from "./DrawTools.js";
import Player from "./Player.js";
import { fetchGeoJSON } from "./fetchGeoJSON.js";
class UserMap extends Component {
constructor(props) {
......@@ -83,9 +82,6 @@ class UserMap extends Component {
}
);
}
// get the layers again to stop updating with old objects
this.fetchGeoJSON();
}
// Get the drawings from the backend and add them to the state, so they can be drawn
......
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