mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-15 05:30:35 +02:00
Cancel debounced history saves in flush() and clearSaved()
This commit is contained in:
@@ -352,6 +352,7 @@ iD.History = function(context) {
|
||||
},
|
||||
|
||||
clearSaved: function() {
|
||||
context.debouncedSave.cancel();
|
||||
if (lock.locked()) context.storage(getKey('saved_history'), null);
|
||||
return history;
|
||||
},
|
||||
|
||||
+3
-2
@@ -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;
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user