Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/Goban/CanvasRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
14 changes: 4 additions & 10 deletions src/Goban/InteractiveBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
9 changes: 3 additions & 6 deletions src/Goban/OGSConnectivity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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;
}

Expand Down
11 changes: 3 additions & 8 deletions src/Goban/SVGRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion test/unit_tests/OGSConnectivity.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe("OGSConnectivity isInPushedAnalysis guard", () => {
expect(consoleErrorSpy).not.toHaveBeenCalledWith(
expect.objectContaining({
message: expect.stringContaining("isInPushedAnalysis is not a function"),
})
}),
);

consoleErrorSpy.mockRestore();
Expand Down
Loading