From 498f5c950c0ce5b919b48590311567ca5ea1c32e Mon Sep 17 00:00:00 2001 From: Jonathan Gamble Date: Wed, 13 Nov 2024 17:40:39 -0600 Subject: [PATCH] remove redundant function --- ui/chess/src/moveRootCtrl.ts | 2 +- ui/round/src/ctrl.ts | 7 ++----- ui/voice/src/move/voice.move.ts | 2 +- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/ui/chess/src/moveRootCtrl.ts b/ui/chess/src/moveRootCtrl.ts index 18f7d89b72096..9aa7f6fc2fdff 100644 --- a/ui/chess/src/moveRootCtrl.ts +++ b/ui/chess/src/moveRootCtrl.ts @@ -12,7 +12,7 @@ export interface MoveRootCtrl { blindfold?: (v?: boolean) => boolean; speakClock?: () => void; goBerserk?: () => void; - shouldConfirmMove?: () => boolean; + confirmMoveToggle?: () => boolean; } export interface MoveUpdate { diff --git a/ui/round/src/ctrl.ts b/ui/round/src/ctrl.ts index 3b1dd0d2f4866..a19346eb2cf49 100644 --- a/ui/round/src/ctrl.ts +++ b/ui/round/src/ctrl.ts @@ -334,16 +334,13 @@ export default class RoundController implements MoveRootCtrl { this.keyboardMove?.update({ fen, canMove: this.canMove() }); }; - shouldConfirmMove = (): boolean => - (this.data.pref.submitMove && this.confirmMoveToggle()) || this.confirmMoveToggle(); - sendMove = (orig: Key, dest: Key, prom: Role | undefined, meta: MoveMetadata): void => { const move: SocketMove = { u: orig + dest }; if (prom) move.u += prom === 'knight' ? 'n' : prom[0]; if (blur.get()) move.b = 1; this.resign(false); - if (!meta.preConfirmed && this.shouldConfirmMove() && !meta.premove) { + if (!meta.preConfirmed && this.confirmMoveToggle() && !meta.premove) { if (site.sound.speech()) { const spoken = `${speakable(sanOf(readFen(this.stepAt(this.ply).fen), move.u))}. confirm?`; site.sound.say(spoken, false, true); @@ -359,7 +356,7 @@ export default class RoundController implements MoveRootCtrl { const drop: SocketDrop = { role, pos: key }; if (blur.get()) drop.b = 1; this.resign(false); - if (this.shouldConfirmMove() && !isPredrop) { + if (this.confirmMoveToggle() && !isPredrop) { this.toSubmit = drop; this.redraw(); } else { diff --git a/ui/voice/src/move/voice.move.ts b/ui/voice/src/move/voice.move.ts index a2c11c4f6bdba..35966aaccf878 100644 --- a/ui/voice/src/move/voice.move.ts +++ b/ui/voice/src/move/voice.move.ts @@ -297,7 +297,7 @@ export function initModule({ // trim choices to clarity window options = options.filter(([, m]) => m.cost - lowestCost <= clarityThreshold); - if (!timer() && options.length === 1 && (options[0][1].cost < 0.3 || root.shouldConfirmMove?.())) { + if (!timer() && options.length === 1 && (options[0][1].cost < 0.3 || root.confirmMoveToggle?.())) { console.info('chooseMoves', `chose '${options[0][0]}' cost=${options[0][1].cost}`); submit(options[0][0], false); return true;