diff --git a/js/id/core/history.js b/js/id/core/history.js index 966e4a567..b256db520 100644 --- a/js/id/core/history.js +++ b/js/id/core/history.js @@ -352,6 +352,7 @@ iD.History = function(context) { }, clearSaved: function() { + context.debouncedSave.cancel(); if (lock.locked()) context.storage(getKey('saved_history'), null); return history; }, diff --git a/js/id/id.js b/js/id/id.js index dbc196727..318f746e9 100644 --- a/js/id/id.js +++ b/js/id/id.js @@ -153,6 +153,7 @@ window.iD = function () { }; context.flush = function() { + context.debouncedSave.cancel(); connection.flush(); features.reset(); history.reset(); @@ -161,11 +162,11 @@ window.iD = function () { // Debounce save, since it's a synchronous localStorage write, // and history changes can happen frequently (e.g. when dragging). - var debouncedSave = _.debounce(context.save, 350); + context.debouncedSave = _.debounce(context.save, 350); function withDebouncedSave(fn) { return function() { var result = fn.apply(history, arguments); - debouncedSave(); + context.debouncedSave(); return result; }; }