Skip to content

Commit

Permalink
Merge branch 'f/implement-multiprocess' into d/erc-paritary
Browse files Browse the repository at this point in the history
  • Loading branch information
selankon committed Nov 15, 2024
2 parents 9125fb2 + d2b3ac8 commit aa0151f
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/components/Process/Chained.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<boolean>(false)
const [loading, setLoading] = useState<boolean>(false)
const [sorted, setSorted] = useState<string[]>([])

// Get elections information
useEffect(() => {
if (!election || election instanceof InvalidElection || loading || loaded) return

setLoading(true)
;(async () => {
try {
Expand All @@ -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 <Progress w='full' size='xs' isIndeterminate />
}
Expand Down

2 comments on commit aa0151f

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.