From 74744319cc1d99b13fe0ccbd6da71889c9cdbc04 Mon Sep 17 00:00:00 2001 From: Dmitri Goldring Date: Thu, 29 Aug 2013 13:58:59 -0400 Subject: [PATCH] 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 --- js/id/ui/commit.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/js/id/ui/commit.js b/js/id/ui/commit.js index 1952d578a..c813d1cf8 100644 --- a/js/id/ui/commit.js +++ b/js/id/ui/commit.js @@ -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) {