diff --git a/src/components/Process/Chained.tsx b/src/components/Process/Chained.tsx index 316df54..8168e93 100644 --- a/src/components/Process/Chained.tsx +++ b/src/components/Process/Chained.tsx @@ -208,14 +208,16 @@ const ChainedProcessesWrapper = () => { const ChainedResultsWrapper = () => { // note election context refers to the root election here, ALWAYS - const { election, client } = useElection() + const { election, client, voted } = useElection() const { processes, setProcess } = useChainedProcesses() const [loaded, setLoaded] = useState(false) const [loading, setLoading] = useState(false) const [sorted, setSorted] = useState([]) + // Get elections information useEffect(() => { if (!election || election instanceof InvalidElection || loading || loaded) return + setLoading(true) ;(async () => { try { @@ -233,6 +235,16 @@ const ChainedResultsWrapper = () => { })() }, [election]) + // Reset loaded state when root election voted changes. + // On renderWith elections this will update all the render elections. + // However, this fix won't work on chained processes since we should check voted state for all processes to update + // results on real time. + useEffect(() => { + if (voted) { + setLoaded(false) + } + }, [voted]) + if (!loaded) { return }