Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fencing: fix double-touch race conditions #123

Merged
merged 2 commits into from
May 4, 2024
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
4 changes: 3 additions & 1 deletion bundle-src/src/graphics/rosesFencing/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ function bannerMsg(round: number) {

export function AllRosesFencingGraphics() {
const state = useOnlyReplicantValue<State & EventMeta>("eventState");
const control = useOnlyReplicantValue<ControlRosesFencing>("control-fencing");
const control = useOnlyReplicantValue<ControlRosesFencing>(
"control-rosesFencing"
);

const now = useTime();

Expand Down
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
Loading