From cecdc012ee15e3c46b81fa4fbd28ad9b0a4c43e9 Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Mon, 27 Apr 2015 11:37:43 -0400 Subject: [PATCH] Don't commit empty changesets.. (closes #1483) instead, silently flush context and return to browse mode --- js/id/modes/save.js | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/js/id/modes/save.js b/js/id/modes/save.js index 83c471c9b..ce8df98a2 100644 --- a/js/id/modes/save.js +++ b/js/id/modes/save.js @@ -134,23 +134,30 @@ iD.modes.Save = function(context) { } else if (errors.length) { showErrors(); } else { - context.connection().putChangeset( - history.changes(iD.actions.DiscardTags(history.difference())), - e.comment, - history.imageryUsed(), - function(err, changeset_id) { - if (err) { - errors.push({ - msg: err.responseText, - details: [ t('save.status_code', { code: err.status }) ] - }); - showErrors(); - } else { - loading.close(); - context.flush(); - success(e, changeset_id); - } - }); + var changes = history.changes(iD.actions.DiscardTags(history.difference())); + if (changes.modified.length || changes.created.length || changes.deleted.length) { + context.connection().putChangeset( + changes, + e.comment, + history.imageryUsed(), + function(err, changeset_id) { + if (err) { + errors.push({ + msg: err.responseText, + details: [ t('save.status_code', { code: err.status }) ] + }); + showErrors(); + } else { + loading.close(); + context.flush(); + success(e, changeset_id); + } + }); + } else { // changes were insignificant or reverted by user + loading.close(); + context.flush(); + cancel(); + } } }