Reset validator whenever reseting the history (close #8108)

This commit is contained in:
Quincy Morgan
2020-10-21 19:30:18 -04:00
parent 99689f65b2
commit 70619d3634
2 changed files with 17 additions and 7 deletions
+2 -1
View File
@@ -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;
},
+15 -6
View File
@@ -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: