Skip to content

Commit

Permalink
Fencing: fix double-touch race conditions (#123)
Browse files Browse the repository at this point in the history
* fix gfx

* Fix double-touch race conditions
  • Loading branch information
markspolakovs authored May 4, 2024
1 parent 85fb561 commit 066fd6d
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions scores-src/src/common/sports/rosesFencing/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,21 @@ const slice = createSlice({
return wrapAction({ payload });
},
},
doubleTap: {
reducer(state) {
state.segmentPoints[state.segmentPoints.length - 1].push({
side: "home",
player: null,
});
state.segmentPoints[state.segmentPoints.length - 1].push({
side: "away",
player: null,
});
},
prepare() {
return wrapAction({ payload: {} });
},
},
resetState: {
reducer(state) {
state.segmentPoints = [];
Expand All @@ -186,6 +201,7 @@ const actionPayloadValidators: ActionPayloadValidators<
player: Yup.string().uuid().optional().nullable(),
}),
resetState: Yup.object({}),
doubleTap: Yup.object({}),
};

const actionValidChecks: ActionValidChecks<State, typeof slice["actions"]> = {};
Expand Down Expand Up @@ -218,10 +234,11 @@ const actionRenderers: ActionRenderers<
</span>
);
},
doubleTap: () => <span>Double touch</span>,
resetState: () => <strong>State reset.</strong>,
};

const hiddenActions = new Set(["addPoints"] as Array<
const hiddenActions = new Set(["addPoints", "doubleTap"] as Array<
keyof typeof slice["actions"]
>);

Expand Down Expand Up @@ -268,8 +285,7 @@ const components: EventComponents<typeof slice["actions"], State> = {
<Button
disabled={state.segmentPoints.length === 0}
onClick={() => {
act("addPoints", { side: "home", points: 1 });
act("addPoints", { side: "away", points: 1 });
act("doubleTap", undefined);
}}
size="lg"
>
Expand Down

0 comments on commit 066fd6d

Please sign in to comment.