@@ -2,7 +2,7 @@ import React, { memo, useState } from 'react';
22import cn from 'classnames' ;
33import { Link } from 'gatsby' ;
44
5- import { useChallengePartIndex , usePersistScrollPosition } from '../../hooks' ;
5+ import { usePersistScrollPosition } from '../../hooks' ;
66
77import * as css from './OverviewTimeline.module.css' ;
88
@@ -20,12 +20,10 @@ const usePaths = (chapters, track, trackPosition) => {
2020 ) ;
2121 const currentVideo =
2222 chapters [ trackPosition . chapterIndex ] . videos [ trackPosition . videoIndex ] ;
23- const totalParts = flatTrack . filter (
24- ( video ) => video . slug === currentVideo . slug
25- ) . length ;
26- const partIndex = useChallengePartIndex ( totalParts ) ;
2723 const currentIndex = flatTrack . findIndex (
28- ( video ) => video . slug === currentVideo . slug && video . partIndex === partIndex
24+ ( video ) =>
25+ video . slug === currentVideo . slug &&
26+ video . partIndex === trackPosition . partIndex
2927 ) ;
3028 const prevVideo = flatTrack [ currentIndex - 1 ] ;
3129 const nextVideo = flatTrack [ currentIndex + 1 ] ;
@@ -39,15 +37,11 @@ const usePaths = (chapters, track, trackPosition) => {
3937 }
4038 return null ;
4139 } ;
42- return [ computePath ( prevVideo ) , computePath ( nextVideo ) , partIndex ] ;
40+ return [ computePath ( prevVideo ) , computePath ( nextVideo ) ] ;
4341} ;
4442
4543const OverviewTimeline = ( { className, chapters, track, trackPosition } ) => {
46- const [ previousVideo , nextVideo , currentPartIndex ] = usePaths (
47- chapters ,
48- track ,
49- trackPosition
50- ) ;
44+ const [ previousVideo , nextVideo ] = usePaths ( chapters , track , trackPosition ) ;
5145
5246 const timelineRef = usePersistScrollPosition ( track . slug , 'tracks' ) ;
5347 return (
@@ -61,7 +55,6 @@ const OverviewTimeline = ({ className, chapters, track, trackPosition }) => {
6155 chapters = { chapters }
6256 track = { track }
6357 trackPosition = { trackPosition }
64- currentPartIndex = { currentPartIndex }
6558 />
6659 ) ) }
6760 </ div >
@@ -82,14 +75,7 @@ const OverviewTimeline = ({ className, chapters, track, trackPosition }) => {
8275} ;
8376
8477const ChapterSection = memo (
85- ( {
86- chapter,
87- chapterIndex,
88- chapters,
89- track,
90- trackPosition,
91- currentPartIndex
92- } ) => {
78+ ( { chapter, chapterIndex, chapters, track, trackPosition } ) => {
9379 const hasSeenChapter = chapterIndex < trackPosition . chapterIndex ;
9480 const isThisChapter = chapterIndex === trackPosition . chapterIndex ;
9581 const trackPath = `/tracks/${ track . slug } ` ;
@@ -125,6 +111,7 @@ const ChapterSection = memo(
125111
126112 return isMultiPart ? (
127113 video . parts . map ( ( part , partIndex ) => {
114+ const currentPartIndex = trackPosition . partIndex ;
128115 const hasSeenPart =
129116 hasSeenVideo &&
130117 ( videoIndex < currentVideoIndex ||
0 commit comments