Skip to content

Commit

Permalink
Fix internal bug with not automatically assigning IDs.
Browse files Browse the repository at this point in the history
  • Loading branch information
theduckylittle committed Nov 8, 2024
1 parent df4cce3 commit 287a79e
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions src/gm3/reducers/mapSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,18 +147,19 @@ const reducer = createReducer(
state[mapSourceName].featuresVersion = 0;
}

// copy assumes a raw dump where the ID does not matter.
for (let i = 0, ii = features.length; !copy && i < ii; i++) {
features[i] = {
...features[i],
properties: {
...features[i].properties,
[ID_PROP]: uuid(),
},
};
}
// ensure features are a list.
const inFeatures = Array.isArray(features) ? features : [features];
const nextFeatures = copy
? inFeatures
: inFeatures.map((feature) => ({
...feature,
properties: {
...feature.properties,
[ID_PROP]: uuid(),
},
}));
state[mapSourceName].features =
state[mapSourceName].features.concat(features);
state[mapSourceName].features.concat(nextFeatures);
state[mapSourceName].featuresVersion += 1;
},
[clearFeatures]: (state, { payload: mapSourceName }) => {
Expand Down

0 comments on commit 287a79e

Please sign in to comment.