@@ -2,7 +2,7 @@ import React, { memo, useState } from 'react';
2
2
import cn from 'classnames' ;
3
3
import { Link } from 'gatsby' ;
4
4
5
- import { useChallengePartIndex , usePersistScrollPosition } from '../../hooks' ;
5
+ import { usePersistScrollPosition } from '../../hooks' ;
6
6
7
7
import * as css from './OverviewTimeline.module.css' ;
8
8
@@ -20,12 +20,10 @@ const usePaths = (chapters, track, trackPosition) => {
20
20
) ;
21
21
const currentVideo =
22
22
chapters [ trackPosition . chapterIndex ] . videos [ trackPosition . videoIndex ] ;
23
- const totalParts = flatTrack . filter (
24
- ( video ) => video . slug === currentVideo . slug
25
- ) . length ;
26
- const partIndex = useChallengePartIndex ( totalParts ) ;
27
23
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
29
27
) ;
30
28
const prevVideo = flatTrack [ currentIndex - 1 ] ;
31
29
const nextVideo = flatTrack [ currentIndex + 1 ] ;
@@ -39,15 +37,11 @@ const usePaths = (chapters, track, trackPosition) => {
39
37
}
40
38
return null ;
41
39
} ;
42
- return [ computePath ( prevVideo ) , computePath ( nextVideo ) , partIndex ] ;
40
+ return [ computePath ( prevVideo ) , computePath ( nextVideo ) ] ;
43
41
} ;
44
42
45
43
const 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 ) ;
51
45
52
46
const timelineRef = usePersistScrollPosition ( track . slug , 'tracks' ) ;
53
47
return (
@@ -61,7 +55,6 @@ const OverviewTimeline = ({ className, chapters, track, trackPosition }) => {
61
55
chapters = { chapters }
62
56
track = { track }
63
57
trackPosition = { trackPosition }
64
- currentPartIndex = { currentPartIndex }
65
58
/>
66
59
) ) }
67
60
</ div >
@@ -82,14 +75,7 @@ const OverviewTimeline = ({ className, chapters, track, trackPosition }) => {
82
75
} ;
83
76
84
77
const ChapterSection = memo (
85
- ( {
86
- chapter,
87
- chapterIndex,
88
- chapters,
89
- track,
90
- trackPosition,
91
- currentPartIndex
92
- } ) => {
78
+ ( { chapter, chapterIndex, chapters, track, trackPosition } ) => {
93
79
const hasSeenChapter = chapterIndex < trackPosition . chapterIndex ;
94
80
const isThisChapter = chapterIndex === trackPosition . chapterIndex ;
95
81
const trackPath = `/tracks/${ track . slug } ` ;
@@ -125,6 +111,7 @@ const ChapterSection = memo(
125
111
126
112
return isMultiPart ? (
127
113
video . parts . map ( ( part , partIndex ) => {
114
+ const currentPartIndex = trackPosition . partIndex ;
128
115
const hasSeenPart =
129
116
hasSeenVideo &&
130
117
( videoIndex < currentVideoIndex ||
0 commit comments