Skip to content

Commit

Permalink
fix changeset implementation in OSM History Widget
Browse files Browse the repository at this point in the history
  • Loading branch information
CollinBeczak committed Feb 15, 2025
1 parent 3eceec6 commit f640f1d
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/services/OSM/OSM.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,21 @@ export const fetchOSMElementHistory = async (idString, includeChangesets = false
const history = await response.json();
if (includeChangesets) {
const changesetIds = map(history.elements, "changeset");
const changesetMap = new Map(await fetchOSMChangesets(changesetIds));
const changesetMap = await fetchOSMChangesets(changesetIds);
const mapfetchedIds = changesetMap.map((c) => c.id);
// Update each history element with its full changeset data
each(history.elements, (entry) => {
if (changesetMap.has(entry.changeset))
entry.changeset = changesetMap.get(entry.changeset);
if (entry.changeset && mapfetchedIds.includes(entry.changeset)) {
// Store the changeset ID before overwriting
const changesetId = entry.changeset;
// Get the full changeset data
const changesetData = changesetMap.find((c) => c.id === changesetId);
// Merge the changeset data while preserving the ID
entry.changeset = {
id: changesetId,
...changesetData,
};
}

Check warning on line 130 in src/services/OSM/OSM.js

View check run for this annotation

Codecov / codecov/patch

src/services/OSM/OSM.js#L121-L130

Added lines #L121 - L130 were not covered by tests
});
}
return history.elements;
Expand Down

0 comments on commit f640f1d

Please sign in to comment.