Skip to content

Commit

Permalink
Merge pull request #1065 from hackforla/FRONT-circle-layer-fix
Browse files Browse the repository at this point in the history
RequestsLayer circle-color fix
  • Loading branch information
adamkendis authored Apr 1, 2021
2 parents 917f365 + abe0cd6 commit a7d8bf9
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion client/components/Map/Map.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ class Map extends React.Component {
}
}

if (this.props.requestTypes != prevProps.requestTypes || !this.map.getSource('requests')) {
if (this.props.requestTypes != prevProps.requestTypes) {
this.requestsLayer.init({
map: this.map,
});
Expand Down
5 changes: 3 additions & 2 deletions client/components/Map/RequestDetail.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -202,13 +202,14 @@ export default connect(mapStateToProps, mapDispatchToProps)(withStyles(styles)(R
RequestDetail.propTypes = {
requestId: PropTypes.number,
pinsInfo: PropTypes.shape({}),
requestTypes: PropTypes.arrayOf(PropTypes.shape({})).isRequired,
requestTypes: PropTypes.arrayOf(PropTypes.shape({})),
agencies: PropTypes.arrayOf(PropTypes.shape({})),
getPinInfo: PropTypes.func.isRequired,
};

RequestDetail.defaultProps = {
requestId: null,
pinsInfo: {},
agencies: [],
agencies: null,
requestTypes: null,
};
9 changes: 7 additions & 2 deletions client/components/Map/layers/RequestsLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,16 @@ function typeFilter(selectedTypes) {
}

class RequestsLayer extends React.Component {
constructor(props) {
super(props);
this.ready = false;
}

init = ({ map }) => {
this.map = map;

this.addSources();
this.addLayers();
this.ready = true;
}

componentDidUpdate(prev) {
Expand All @@ -50,7 +55,7 @@ class RequestsLayer extends React.Component {
if (selectedTypes !== prev.selectedTypes)
this.setSelectedTypes(selectedTypes);

if (requests !== prev.requests)
if (requests !== prev.requests && this.ready)
this.setRequests(requests);

if (colorScheme !== prev.colorScheme)
Expand Down
10 changes: 5 additions & 5 deletions client/components/main/Desktop/RequestTypeSelector/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ export default connect(
)(RequestTypeSelector);

RequestTypeSelector.propTypes = {
requestTypes: PropTypes.arrayOf(PropTypes.shape({
typeId: PropTypes.number,
typeName: PropTypes.string,
color: PropTypes.string,
})).isRequired,
requestTypes: PropTypes.arrayOf(PropTypes.shape({})),
updateTypesFilter: PropTypes.func.isRequired,
};

RequestTypeSelector.defaultProps = {
requestTypes: null,
};
2 changes: 1 addition & 1 deletion client/redux/reducers/metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const initialState = {
version: null,
lastPulledUTC: null,
lastPulledLocal: null,
requestTypes: [],
requestTypes: null,
councils: null,
regions: null,
agencies: null,
Expand Down

0 comments on commit a7d8bf9

Please sign in to comment.