From 1050faab8f8b66e163551b02131eb040b679110d Mon Sep 17 00:00:00 2001 From: Ansis Brammanis Date: Wed, 13 Feb 2013 17:42:46 -0500 Subject: [PATCH] Only delete saved on hitting reset, fixes #744 --- js/id/core/history.js | 14 ++++++++------ js/id/ui/restore.js | 3 ++- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/js/id/core/history.js b/js/id/core/history.js index 47c93c145..bfd0d5a8c 100644 --- a/js/id/core/history.js +++ b/js/id/core/history.js @@ -175,12 +175,7 @@ iD.History = function(context) { if (!lock) return; context.storage(getKey('lock'), null); - if (stack.length <= 1) { - context.storage(getKey('history'), null); - context.storage(getKey('nextIDs'), null); - context.storage(getKey('index'), null); - return; - } + if (stack.length <= 1) return; var json = JSON.stringify(stack.map(function(i) { return { @@ -198,6 +193,13 @@ iD.History = function(context) { context.storage(getKey('index'), index); }, + clearSaved: function() { + if (!lock) return; + context.storage(getKey('history'), null); + context.storage(getKey('nextIDs'), null); + context.storage(getKey('index'), null); + }, + lock: function() { if (context.storage(getKey('lock'))) return false; context.storage(getKey('lock'), true); diff --git a/js/id/ui/restore.js b/js/id/ui/restore.js index d15f80d96..c6996ff23 100644 --- a/js/id/ui/restore.js +++ b/js/id/ui/restore.js @@ -34,7 +34,8 @@ iD.ui.Restore = function(context) { .attr('class', 'cancel button col6') .text(t('restore.reset')) .on('click', function() { + context.history().clearSaved(); modal.remove(); }); - } + }; };