Skip to content

Commit

Permalink
remove post voting instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
kshen0 committed Oct 10, 2023
1 parent 22abecd commit d2ac466
Showing 1 changed file with 2 additions and 35 deletions.
37 changes: 2 additions & 35 deletions apps/mark-scan/frontend/src/app_root.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useCallback, useEffect, useReducer, useRef } from 'react';
import React, { useCallback, useEffect, useReducer } from 'react';
import {
ElectionDefinition,
OptionalElectionDefinition,
Expand Down Expand Up @@ -88,7 +88,6 @@ import { CastingBallotPage } from './pages/casting_ballot_page';

interface UserState {
votes?: VotesDict;
showPostVotingInstructions?: boolean;
}

interface SharedState {
Expand Down Expand Up @@ -128,7 +127,6 @@ export const blankBallotVotes: VotesDict = {};

const initialVoterState: Readonly<UserState> = {
votes: undefined,
showPostVotingInstructions: undefined,
};

const initialSharedState: Readonly<SharedState> = {
Expand Down Expand Up @@ -162,7 +160,7 @@ type AppAction =
| { type: 'unconfigure' }
| { type: 'updateVote'; contestId: ContestId; vote: OptionalVote }
| { type: 'forceSaveVote' }
| { type: 'resetBallot'; showPostVotingInstructions?: boolean }
| { type: 'resetBallot' }
| { type: 'enableLiveMode' }
| { type: 'toggleLiveMode' }
| { type: 'updatePollsState'; pollsState: PollsState }
Expand Down Expand Up @@ -203,7 +201,6 @@ function appReducer(state: State, action: AppAction): State {
return {
...state,
...initialVoterState,
showPostVotingInstructions: action.showPostVotingInstructions,
};
case 'enableLiveMode':
return {
Expand Down Expand Up @@ -256,15 +253,13 @@ export function AppRoot({
reload,
logger,
}: Props): JSX.Element | null {
const PostVotingInstructionsTimeout = useRef(0);
const [appState, dispatchAppState] = useReducer(appReducer, initialAppState);
const {
ballotsPrintedCount,
electionDefinition: optionalElectionDefinition,
isLiveMode,
pollsState,
initializedFromStorage,
showPostVotingInstructions,
votes,
} = appState;

Expand Down Expand Up @@ -367,7 +362,6 @@ export function AppRoot({
(newShowPostVotingInstructions?: boolean) => {
dispatchAppState({
type: 'resetBallot',
showPostVotingInstructions: newShowPostVotingInstructions,
});
history.push('/');

Expand All @@ -380,33 +374,6 @@ export function AppRoot({
[history, themeManager]
);

const hidePostVotingInstructions = useCallback(() => {
clearTimeout(PostVotingInstructionsTimeout.current);
endCardlessVoterSessionMutate(undefined, {
onSuccess() {
resetBallot();
},
});
}, [endCardlessVoterSessionMutate, resetBallot]);

// Hide Verify and Scan Instructions
useEffect(() => {
if (showPostVotingInstructions) {
PostVotingInstructionsTimeout.current = window.setTimeout(
hidePostVotingInstructions,
GLOBALS.BALLOT_INSTRUCTIONS_TIMEOUT_SECONDS * 1000
);
}
return () => {
clearTimeout(PostVotingInstructionsTimeout.current);
};
/* We don't include hidePostVotingInstructions because it is updated
* frequently due to its dependency on auth, which causes this effect to
* run/cleanup,clearing the timeout.
*/
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [showPostVotingInstructions]);

const unconfigure = useCallback(async () => {
await storage.clear();

Expand Down

0 comments on commit d2ac466

Please sign in to comment.