mirror of
https://github.com/FoggedLens/iD.git
synced 2026-06-03 13:38:04 +02:00
Reset validator whenever reseting the history (close #8108)
This commit is contained in:
@@ -15,7 +15,7 @@ import {
|
||||
|
||||
|
||||
export function coreHistory(context) {
|
||||
var dispatch = d3_dispatch('change', 'merge', 'restore', 'undone', 'redone');
|
||||
var dispatch = d3_dispatch('reset', 'change', 'merge', 'restore', 'undone', 'redone');
|
||||
var lock = utilSessionMutex('lock');
|
||||
|
||||
// restorable if iD not open in another window/tab and a saved history exists in localStorage
|
||||
@@ -362,6 +362,7 @@ export function coreHistory(context) {
|
||||
_tree = coreTree(_stack[0].graph);
|
||||
_checkpoints = {};
|
||||
}
|
||||
dispatch.call('reset');
|
||||
dispatch.call('change');
|
||||
return history;
|
||||
},
|
||||
|
||||
@@ -40,21 +40,24 @@ export function coreValidator(context) {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// clear caches, called whenever iD resets after a save
|
||||
//
|
||||
validator.reset = function() {
|
||||
function reset(resetIgnored) {
|
||||
Array.from(_deferred).forEach(function(handle) {
|
||||
window.cancelIdleCallback(handle);
|
||||
_deferred.delete(handle);
|
||||
});
|
||||
|
||||
// clear caches
|
||||
_ignoredIssueIDs = {};
|
||||
if (resetIgnored) _ignoredIssueIDs = {};
|
||||
_baseCache = validationCache();
|
||||
_headCache = validationCache();
|
||||
_validatedGraph = null;
|
||||
}
|
||||
|
||||
//
|
||||
// clear caches, called whenever iD resets after a save
|
||||
//
|
||||
validator.reset = function() {
|
||||
reset(true);
|
||||
};
|
||||
|
||||
validator.resetIgnoredIssues = function() {
|
||||
@@ -404,6 +407,12 @@ export function coreValidator(context) {
|
||||
dispatch.call('validated');
|
||||
};
|
||||
|
||||
context.history()
|
||||
.on('reset.validator', function() {
|
||||
// cached issues aren't valid any longer if the history has been reset
|
||||
reset(false);
|
||||
validator.validate();
|
||||
});
|
||||
|
||||
// WHEN TO RUN VALIDATION:
|
||||
// When graph changes:
|
||||
|
||||
Reference in New Issue
Block a user