From 83a1685f749ffe7647fa2fa2fa6ab84edaf6bd0a Mon Sep 17 00:00:00 2001 From: JannisX11 Date: Thu, 8 Jun 2023 20:19:47 +0200 Subject: [PATCH] Add validate method to individual checks Fix switching elements to per face UV in validator --- js/validator.js | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/js/validator.js b/js/validator.js index 679be9ac..20a6a4b3 100644 --- a/js/validator.js +++ b/js/validator.js @@ -96,6 +96,7 @@ class ValidatorCheck { this.run = options.run; this.errors = []; this.warnings = []; + this._timeout = null; Validator.checks.push(this); Validator.updateCashedTriggers(); @@ -116,6 +117,26 @@ class ValidatorCheck { console.error(error); } } + validate() { + if (this._timeout) { + clearTimeout(this._timeout); + this._timeout = null; + } + + this._timeout = setTimeout(() => { + this._timeout = null; + + this.update(); + + Validator.warnings.empty(); + Validator.errors.empty(); + + Validator.checks.forEach(check => { + Validator.warnings.push(...check.warnings); + Validator.errors.push(...check.errors); + }) + }, 40) + } warn(...warnings) { this.warnings.push(...warnings); } @@ -186,15 +207,10 @@ new ValidatorCheck('box_uv', { click() { Validator.dialog.hide(); - save = Undo.initEdit({uv_mode: true}) - Project.box_uv = false; - Canvas.updateAllUVs() - updateSelection() - Undo.finishEdit('Change project UV settings') - BARS.updateConditions() - if (Project.EditSession) { - Project.EditSession.sendAll('change_project_meta', JSON.stringify({box_uv: false})); - } + Undo.initEdit({elements: [cube], uv_only: true}); + cube.setUVMode(false); + Undo.finishEdit('Change UV mode') + updateSelection(); } }) }