Skip to content
This repository was archived by the owner on Nov 3, 2020. It is now read-only.
Open
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
9 changes: 7 additions & 2 deletions client/src/AppRoot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export const configuredAtStorageKey = 'configuredAt'

const AppRoot = ({ storage }: Props) => {
const printBallotRef = useRef<HTMLDivElement>(null)
const [isFetchingElection, setIsFetchingElection] = useState(true)

const getElection = async () => {
const election = await storage.get(electionStorageKey)
Expand Down Expand Up @@ -139,21 +140,21 @@ const AppRoot = ({ storage }: Props) => {
useEffect(() => {
;(async () => {
if (!election) {
setIsFetchingElection(true)
const storageElection = await getElection()
if (storageElection) {
setElection(storageElection)
setElectionHash(sha256(JSON.stringify(storageElection)))

setConfiguredAt((await storage.get(configuredAtStorageKey)) || '')
}

if (castVoteRecordFiles === CastVoteRecordFiles.empty) {
const storageCVRFiles = await getCVRFiles()
if (storageCVRFiles) {
setCastVoteRecordFiles(CastVoteRecordFiles.import(storageCVRFiles))
setIsOfficialResults((await getIsOfficialResults()) || false)
}
}
setIsFetchingElection(false)
}
})()
})
Expand Down Expand Up @@ -197,6 +198,10 @@ const AppRoot = ({ storage }: Props) => {
}
}

if (isFetchingElection) {
return null
}

return (
<AppContext.Provider
value={{
Expand Down