Skip to content

Commit

Permalink
Simplify some stuff in replay.ts by inlining a couple functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
johndoknjas committed Dec 12, 2024
1 parent 9630ee8 commit 6a5a548
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions ui/round/src/view/replay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,14 @@ export function analysisButton(ctrl: RoundController): LooseVNode {
);
}

const targetPly = (e: Event) => parseInt((e.target as HTMLElement).getAttribute('data-ply') || '');

const goToPly = (e: Event, ctrl: RoundController) => () => {
const ply = targetPly(e);
if (!isNaN(ply)) ctrl.userJump(ply);
ctrl.redraw();
};

const goThroughMoves = (ctrl: RoundController, e: Event) => replayMovesRepeater(goToPly(e, ctrl), e);
const goThroughMoves = (ctrl: RoundController, e: Event) => replayMovesRepeater(
() => {
const ply = parseInt((e.target as HTMLElement).getAttribute('data-ply') || '');
if (!isNaN(ply)) ctrl.userJump(ply);
ctrl.redraw();
},
e
);

function renderButtons(ctrl: RoundController) {
const firstPly = util.firstPly(ctrl.data),
Expand Down

0 comments on commit 6a5a548

Please sign in to comment.