From c4196e3ef0b7ada1507f06a74f83ca8d6c233327 Mon Sep 17 00:00:00 2001 From: Akita Noek Date: Thu, 6 Nov 2025 14:02:30 -0700 Subject: [PATCH] Fix undefiend inPushedAnalysis calls --- src/Goban/CanvasRenderer.ts | 6 ++---- src/Goban/InteractiveBase.ts | 14 ++++---------- src/Goban/OGSConnectivity.ts | 9 +++------ src/Goban/SVGRenderer.ts | 11 +++-------- test/unit_tests/OGSConnectivity.test.ts | 2 +- 5 files changed, 13 insertions(+), 29 deletions(-) diff --git a/src/Goban/CanvasRenderer.ts b/src/Goban/CanvasRenderer.ts index 790640f0..a2fe2b5f 100644 --- a/src/Goban/CanvasRenderer.ts +++ b/src/Goban/CanvasRenderer.ts @@ -1279,8 +1279,7 @@ export class GobanCanvas extends Goban implements GobanCanvasInterface { if ( this.engine && this.engine.cur_move && - (this.mode !== "play" || - (typeof this.isInPushedAnalysis() !== "undefined" && this.isInPushedAnalysis())) + (this.mode !== "play" || this.isInPushedAnalysis?.()) ) { let cur: MoveTree | null = this.engine.cur_move; for (; cur && !cur.trunk; cur = cur.parent) { @@ -2309,8 +2308,7 @@ export class GobanCanvas extends Goban implements GobanCanvasInterface { if ( this.engine && this.engine.cur_move && - (this.mode !== "play" || - (typeof this.isInPushedAnalysis() !== "undefined" && this.isInPushedAnalysis())) + (this.mode !== "play" || this.isInPushedAnalysis?.()) ) { let cur: MoveTree | null = this.engine.cur_move; for (; cur && !cur.trunk; cur = cur.parent) { diff --git a/src/Goban/InteractiveBase.ts b/src/Goban/InteractiveBase.ts index 42ac65f1..42a9d552 100644 --- a/src/Goban/InteractiveBase.ts +++ b/src/Goban/InteractiveBase.ts @@ -254,8 +254,8 @@ export abstract class GobanInteractive extends GobanBase { protected getPuzzlePlacementSetting?: () => PuzzlePlacementSetting; protected highlight_movetree_moves: boolean; protected interactive: boolean; - protected isInPushedAnalysis: () => boolean; - protected leavePushedAnalysis: () => void; + protected isInPushedAnalysis?: () => boolean; + protected leavePushedAnalysis?: () => void; protected isPlayerController: () => boolean; protected isPlayerOwner: () => boolean; protected label_character: string; @@ -356,14 +356,8 @@ export abstract class GobanInteractive extends GobanBase { this.puzzle_autoplace_delay = config.puzzle_autoplace_delay || 300; this.isPlayerOwner = config.isPlayerOwner || (() => false); /* for reviews */ this.isPlayerController = config.isPlayerController || (() => false); /* for reviews */ - this.isInPushedAnalysis = config.isInPushedAnalysis - ? config.isInPushedAnalysis - : () => false; - this.leavePushedAnalysis = config.leavePushedAnalysis - ? config.leavePushedAnalysis - : () => { - return; - }; + this.isInPushedAnalysis = config.isInPushedAnalysis ?? (() => false); + this.leavePushedAnalysis = config.leavePushedAnalysis ?? (() => {}); //this.onPendingResignation = config.onPendingResignation; //this.onPendingResignationCleared = config.onPendingResignationCleared; if ("onError" in config) { diff --git a/src/Goban/OGSConnectivity.ts b/src/Goban/OGSConnectivity.ts index 47814dbe..d212d809 100644 --- a/src/Goban/OGSConnectivity.ts +++ b/src/Goban/OGSConnectivity.ts @@ -548,11 +548,8 @@ export abstract class OGSConnectivity extends GobanInteractive { } const move = move_obj.move; - if ( - typeof this.isInPushedAnalysis === "function" && - this.isInPushedAnalysis() - ) { - this.leavePushedAnalysis(); + if (this.isInPushedAnalysis?.()) { + this.leavePushedAnalysis?.(); } /* clear any undo state that may be hanging around */ @@ -1168,7 +1165,7 @@ export abstract class OGSConnectivity extends GobanInteractive { (this.isPlayerOwner() && msg_override && msg_override.controller)) && this.done_loading_review ) { - if (typeof this.isInPushedAnalysis === "function" && this.isInPushedAnalysis()) { + if (this.isInPushedAnalysis?.()) { return; } diff --git a/src/Goban/SVGRenderer.ts b/src/Goban/SVGRenderer.ts index c51809e5..baeda1d1 100644 --- a/src/Goban/SVGRenderer.ts +++ b/src/Goban/SVGRenderer.ts @@ -1366,9 +1366,7 @@ export class SVGRenderer extends Goban implements GobanSVGInterface { this.engine && this.engine.cur_move && (this.mode !== "play" || - (typeof this.isInPushedAnalysis() !== "undefined" && - this.isInPushedAnalysis() && - this.show_variation_move_numbers)) + (this.isInPushedAnalysis?.() && this.show_variation_move_numbers)) ) { let cur: MoveTree | null = this.engine.cur_move; for (; cur && !cur.trunk; cur = cur.parent) { @@ -2087,9 +2085,7 @@ export class SVGRenderer extends Goban implements GobanSVGInterface { this.engine && this.engine.cur_move && (this.mode !== "play" || - (typeof this.isInPushedAnalysis() !== "undefined" && - this.isInPushedAnalysis() && - this.show_variation_move_numbers)) + (this.isInPushedAnalysis?.() && this.show_variation_move_numbers)) ) { let cur: MoveTree | null = this.engine.cur_move; for (; cur && !cur.trunk; cur = cur.parent) { @@ -3169,8 +3165,7 @@ export class SVGRenderer extends Goban implements GobanSVGInterface { if ( this.engine && this.engine.cur_move && - (this.mode !== "play" || - (typeof this.isInPushedAnalysis() !== "undefined" && this.isInPushedAnalysis())) + (this.mode !== "play" || this.isInPushedAnalysis?.()) ) { let cur: MoveTree | null = this.engine.cur_move; for (; cur && !cur.trunk; cur = cur.parent) { diff --git a/test/unit_tests/OGSConnectivity.test.ts b/test/unit_tests/OGSConnectivity.test.ts index 9517c31b..410fadf6 100644 --- a/test/unit_tests/OGSConnectivity.test.ts +++ b/test/unit_tests/OGSConnectivity.test.ts @@ -36,7 +36,7 @@ describe("OGSConnectivity isInPushedAnalysis guard", () => { expect(consoleErrorSpy).not.toHaveBeenCalledWith( expect.objectContaining({ message: expect.stringContaining("isInPushedAnalysis is not a function"), - }) + }), ); consoleErrorSpy.mockRestore();