Skip to content

Commit

Permalink
Small but important fix for #682:
Browse files Browse the repository at this point in the history
- MapSwitcher expects an array (as it runs .map() on the property) from backend.
- Also updated the comment in client to better reflect the current state of affairs.
  • Loading branch information
jacobwod committed Mar 4, 2021
1 parent 6fbc9dd commit a14def3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion new-backend/server/api/services/config.service.v2.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ class ConfigServiceV2 {

// Finally, take a look in LayerSwitcher.options and see
// whether user specific maps are needed. If so, grab them.
let userSpecificMaps = null; // Set to null, client looks for this key!
let userSpecificMaps = []; // Set to empty array, client will do .map() on it.
if (mapConfig.map.mapselector === true) {
userSpecificMaps = await this.getUserSpecificMaps(user);
}
Expand Down
9 changes: 4 additions & 5 deletions new-client/src/controls/MapSwitcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,10 @@ class MapSwitcher extends React.PureComponent {
componentDidMount() {
let { proxy, mapserviceBase } = this.appModel.config.appConfig;

// If user specific maps already exist in config, there's no need
// to fetch again (the new API provides this). Please note that
// it will be null if map doesn't want to show the map selector -
// hence we look for undefined specifically: the old API will not
// provide this property at all.
// If user specific maps is provided by the new API, the key will
// already exist in config and there's no need to fetch again.
// However, if it's undefined, it looks like we're using the old API
// and MapSwitcher must do the fetch by itself.
if (this.appModel.config.userSpecificMaps !== undefined) {
this.handleLoading(this.appModel.config.userSpecificMaps);
} else {
Expand Down

0 comments on commit a14def3

Please sign in to comment.