Skip to content

Commit

Permalink
Fix svg theme setting callback not working the first change
Browse files Browse the repository at this point in the history
  • Loading branch information
anoek committed Aug 26, 2024
1 parent 9a920d3 commit 1aaaa51
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 16 deletions.
2 changes: 1 addition & 1 deletion engine/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
16 changes: 2 additions & 14 deletions src/Goban/SVGRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down

0 comments on commit 1aaaa51

Please sign in to comment.