Skip to content

Commit b2f3cc2

Browse files
kappu72offtherailz
authored andcommitted
Fix #3186. Fix Firefox 62/Chrome 69 flat function conflicts (#3187)
1 parent d6704ff commit b2f3cc2

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

web/client/selectors/__tests__/layers-test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ describe('Test layers selectors', () => {
3232
expect(props[0].type).toBe("osm");
3333
});
3434

35+
it('test layersSelector without layers', () => {
36+
const props = layersSelector({});
37+
expect(props).toExist();
38+
expect(props.length).toBe(0);
39+
});
40+
3541
it('test layerSelectorWithMarkers with no markers', () => {
3642
const props = layerSelectorWithMarkers({config: {layers: [{type: "osm"}]}});
3743

web/client/selectors/layers.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ const {createSelector} = require('reselect');
1111
const MapInfoUtils = require('../utils/MapInfoUtils');
1212
const LayersUtils = require('../utils/LayersUtils');
1313
const {getNormalizedLatLon} = require('../utils/CoordinatesUtils');
14-
const {get, head, isEmpty, find, isObject, castArray} = require('lodash');
14+
const {get, head, isEmpty, find, isObject, isArray, castArray} = require('lodash');
1515

16-
const layersSelector = state => state.layers && state.layers.flat || state.layers || state.config && state.config.layers || [];
16+
const layersSelector = ({layers, config} = {}) => layers && isArray(layers) ? layers : layers && layers.flat || config && config.layers || [];
1717
const currentBackgroundLayerSelector = state => head(layersSelector(state).filter(l => l && l.visibility && l.group === "background"));
1818
const getLayerFromId = (state, id) => head(layersSelector(state).filter(l => l.id === id));
1919
const allBackgroundLayerSelector = state => layersSelector(state).filter(l => l.group === "background");

0 commit comments

Comments
 (0)