From 70619d36345e2182396136696497f48f8f4df3f8 Mon Sep 17 00:00:00 2001 From: Quincy Morgan <2046746+quincylvania@users.noreply.github.com> Date: Wed, 21 Oct 2020 19:30:18 -0400 Subject: [PATCH] Reset validator whenever reseting the history (close #8108) --- modules/core/history.js | 3 ++- modules/core/validator.js | 21 +++++++++++++++------ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/modules/core/history.js b/modules/core/history.js index 841c12677..dc6adb172 100644 --- a/modules/core/history.js +++ b/modules/core/history.js @@ -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; }, diff --git a/modules/core/validator.js b/modules/core/validator.js index 603642a1c..e546ae606 100644 --- a/modules/core/validator.js +++ b/modules/core/validator.js @@ -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: