diff --git a/packages/frontend/src/components/Election/Admin/SendEmailDialog.tsx b/packages/frontend/src/components/Election/Admin/SendEmailDialog.tsx index 04384385d..61b9120ab 100644 --- a/packages/frontend/src/components/Election/Admin/SendEmailDialog.tsx +++ b/packages/frontend/src/components/Election/Admin/SendEmailDialog.tsx @@ -72,12 +72,17 @@ const SendEmailDialog = ({open, onClose, onSubmit, targetedEmail=undefined, elec })) } + // The backend re-queries the roll when it sends, so this count has to be of + // the same thing it will find. The roll is refetched when the dialog is + // opened; before that fix the button could offer to send to voters who had + // already voted since the page was loaded (#1287). const getVoterCount = () => { if(!electionRoll) return 0; if(audience == 'single') return 1; if(audience == 'all') return electionRoll.length; if(audience == 'has_voted') return electionRoll.filter(roll => roll.submitted).length if(audience == 'has_not_voted') return electionRoll.filter(roll => !roll.submitted).length + return 0; } const warning: string = (() => { @@ -174,7 +179,7 @@ const SendEmailDialog = ({open, onClose, onSubmit, targetedEmail=undefined, elec } { setTemplateChosen(false) onSubmit({ diff --git a/packages/frontend/src/components/Election/Admin/ViewElectionRolls.tsx b/packages/frontend/src/components/Election/Admin/ViewElectionRolls.tsx index dd90e0872..6a6f0957c 100644 --- a/packages/frontend/src/components/Election/Admin/ViewElectionRolls.tsx +++ b/packages/frontend/src/components/Election/Admin/ViewElectionRolls.tsx @@ -167,7 +167,7 @@ const ViewElectionRolls = () => { } {usesEmail && - setDialogOpen(true)} sx={{ml: 2}}>Draft Email Blast + { fetchRolls(); setDialogOpen(true); }} sx={{ml: 2}}>Draft Email Blast } {canClearRolls &&