Use dictionary instead of array to prevent split changes

Changesets for a new area can be out of order, this patch
fixes an issue where they could show up in the commit confirm
as 'point, area, point(s)' instead of 'points, area'.

Fixes #1722
This commit is contained in:
Dmitri Goldring
2013-08-29 13:58:59 -04:00
committed by John Firebaugh
parent 77c0b5041e
commit 74744319cc

View File

@@ -3,7 +3,7 @@ iD.ui.Commit = function(context) {
presets = context.presets();
function zipSame(d) {
var c = [], n = -1;
var c = {}, n = -1;
for (var i = 0; i < d.length; i++) {
var desc = {
name: d[i].tags.name || presets.match(d[i], context.graph()).name(),
@@ -11,15 +11,15 @@ iD.ui.Commit = function(context) {
count: 1,
tagText: iD.util.tagText(d[i])
};
if (c[n] &&
c[n].name == desc.name &&
c[n].tagText == desc.tagText) {
c[n].count++;
var fingerprint = desc.name + desc.tagText;
if (c[fingerprint]) {
c[fingerprint].count++;
} else {
c[++n] = desc;
c[fingerprint] = desc;
}
}
return c;
return _.values(c);
}
function commit(selection) {