From 1aaaa517035cfcd282268f8326f059c92235f331 Mon Sep 17 00:00:00 2001 From: Akita Noek Date: Mon, 26 Aug 2024 14:14:44 -0600 Subject: [PATCH] Fix svg theme setting callback not working the first change --- engine/package.json | 2 +- package.json | 2 +- src/Goban/SVGRenderer.ts | 16 ++-------------- 3 files changed, 4 insertions(+), 16 deletions(-) diff --git a/engine/package.json b/engine/package.json index 04e06dd5..9430da5f 100644 --- a/engine/package.json +++ b/engine/package.json @@ -1,6 +1,6 @@ { "name": "goban-engine", - "version": "8.3.30", + "version": "8.3.31", "description": "", "main": "build/goban-engine.js", "types": "build/engine/index.d.ts", diff --git a/package.json b/package.json index 110222e7..a5b13cd9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "goban", - "version": "8.3.30", + "version": "8.3.31", "description": "", "main": "build/goban.js", "types": "build/src/index.d.ts", diff --git a/src/Goban/SVGRenderer.ts b/src/Goban/SVGRenderer.ts index ac2b83b1..918be74c 100644 --- a/src/Goban/SVGRenderer.ts +++ b/src/Goban/SVGRenderer.ts @@ -203,28 +203,16 @@ export class SVGRenderer extends Goban implements GobanSVGInterface { window.addEventListener("keydown", this.handleShiftKey); window.addEventListener("keyup", this.handleShiftKey); - // these are set in this.setThemes(..) - // this.theme_board - // this.theme_white - // this.theme_black this.setTheme(this.getSelectedThemes(), true); - let first_pass = true; const watcher = this.watchSelectedThemes((themes: GobanSelectedThemes) => { if (!this.engine) { + console.error("Engine not initialized yet, ignoring theme change"); return; } - if ( - themes.black === "Custom" || - themes.white === "Custom" || - themes.board === "Custom" - ) { - //first_pass = true; - } delete __theme_cache.black?.["Custom"]; delete __theme_cache.white?.["Custom"]; delete __theme_cache.board?.["Custom"]; - this.setTheme(themes, first_pass ? true : false); - first_pass = false; + this.setTheme(themes, false); }); this.on("destroy", () => watcher.remove());