@@ -68,7 +68,7 @@ const Timeline: React.FC<{
6868 currentPeriodIndex : number ;
6969} > = ( { currentPeriodIndex, dispute } ) => {
7070 const currentItemIndex = currentPeriodToCurrentItem ( currentPeriodIndex , dispute ?. court . hiddenVotes ) ;
71- const items = useTimeline ( dispute , currentItemIndex , currentItemIndex ) ;
71+ const items = useTimeline ( dispute , currentPeriodIndex ) ;
7272
7373 return (
7474 < TimeLineContainer >
@@ -103,41 +103,43 @@ const currentPeriodToCurrentItem = (currentPeriodIndex: number, hiddenVotes?: bo
103103 else return currentPeriodIndex - 1 ;
104104} ;
105105
106- const useTimeline = ( dispute : DisputeDetailsQuery [ "dispute" ] , currentItemIndex : number , currentPeriodIndex : number ) => {
106+ const useTimeline = ( dispute : DisputeDetailsQuery [ "dispute" ] , currentPeriodIndex : number ) => {
107107 const isDesktop = useIsDesktop ( ) ;
108- const titles = useMemo ( ( ) => {
109- const titles = [ "Evidence" , "Voting" , "Appeal" , "Executed" ] ;
110- if ( dispute ?. court . hiddenVotes ) {
111- titles . splice ( 1 , 0 , "Commit" ) ;
112- }
113- return titles ;
114- } , [ dispute ] ) ;
108+ const titles = [ "Evidence" , "Commit" , "Voting" , "Appeal" , "Executed" ] ;
109+
115110 const deadlineCurrentPeriod = getDeadline (
116111 currentPeriodIndex ,
117112 dispute ?. lastPeriodChange ,
118113 dispute ?. court . timesPerPeriod
119114 ) ;
115+
120116 const countdown = useCountdown ( deadlineCurrentPeriod ) ;
121117 const getSubitems = ( index : number ) : string [ ] | React . ReactNode [ ] => {
122118 if ( typeof countdown !== "undefined" && dispute ) {
123119 if ( index === titles . length - 1 ) {
124120 return [ ] ;
125- } else if ( index === currentItemIndex && countdown === 0 ) {
121+ } else if ( index === currentPeriodIndex && countdown === 0 ) {
126122 return [ "Time's up!" ] ;
127- } else if ( index < currentItemIndex ) {
123+ } else if ( index < currentPeriodIndex ) {
128124 return [ ] ;
129- } else if ( index === currentItemIndex ) {
125+ } else if ( index === currentPeriodIndex ) {
130126 return [ secondsToDayHourMinute ( countdown ) ] ;
131127 } else {
132128 return [ secondsToDayHourMinute ( dispute ?. court . timesPerPeriod [ index ] ) ] ;
133129 }
134130 }
135131 return [ < StyledSkeleton key = { index } width = { 60 } /> ] ;
136132 } ;
137- return titles . map ( ( title , i ) => ( {
138- title : i + 1 < titles . length && isDesktop ? `${ title } Period` : title ,
139- subitems : getSubitems ( i ) ,
140- } ) ) ;
133+ return titles . flatMap ( ( title , i ) => {
134+ // if not hidden votes, skip commit index
135+ if ( ! dispute ?. court . hiddenVotes && i === Periods . commit ) return [ ] ;
136+ return [
137+ {
138+ title : i + 1 < titles . length && isDesktop ? `${ title } Period` : title ,
139+ subitems : getSubitems ( i ) ,
140+ } ,
141+ ] ;
142+ } ) ;
141143} ;
142144
143145export const getDeadline = (
0 commit comments