@@ -125,12 +125,7 @@ const ScanResults: FC<Props> = ({ data }) => {
125
125
} , [ data ?. courseUpdates , data ?. customPages , intl ] ) ;
126
126
127
127
// Combine renderable sections with regular sections
128
- const allSectionsForBrokenLinks = useMemo (
129
- ( ) => [ ...renderableSections , ...( sections || [ ] ) ] ,
130
- [ renderableSections , sections ] ,
131
- ) ;
132
-
133
- const allSectionsForPrevRun = useMemo (
128
+ const allSections = useMemo (
134
129
( ) => [ ...renderableSections , ...( sections || [ ] ) ] ,
135
130
[ renderableSections , sections ] ,
136
131
) ;
@@ -139,21 +134,21 @@ const ScanResults: FC<Props> = ({ data }) => {
139
134
brokenLinksCounts,
140
135
lockedLinksCounts,
141
136
externalForbiddenLinksCounts,
142
- } = useMemo ( ( ) => countBrokenLinks ( { sections : allSectionsForBrokenLinks } ) , [ allSectionsForBrokenLinks ] ) ;
137
+ } = useMemo ( ( ) => countBrokenLinks ( { sections : allSections } ) , [ allSections ] ) ;
143
138
144
139
// Calculate if there are any previous run links across all sections
145
140
const hasPreviousRunLinks = useMemo (
146
- ( ) => allSectionsForPrevRun . some ( section => (
141
+ ( ) => allSections . some ( section => (
147
142
section . subsections . some ( subsection => subsection . units . some ( unit => (
148
143
unit . blocks . some ( block => block . previousRunLinks && block . previousRunLinks . length > 0 )
149
144
) ) ) ) ) ,
150
- [ allSectionsForPrevRun ] ,
145
+ [ allSections ] ,
151
146
) ;
152
147
153
- // Calculate previous run links count for each section (including virtual sections)
148
+ // Calculate previous run links count for each section
154
149
const previousRunLinksCounts = useMemo ( ( ) => {
155
- if ( ! allSectionsForPrevRun ) { return [ ] ; }
156
- return allSectionsForPrevRun . map ( section => section . subsections . reduce (
150
+ if ( ! allSections ) { return [ ] ; }
151
+ return allSections . map ( section => section . subsections . reduce (
157
152
( sectionTotal , subsection ) => sectionTotal
158
153
+ subsection . units . reduce (
159
154
( unitTotal , unit ) => unitTotal
@@ -165,17 +160,17 @@ const ScanResults: FC<Props> = ({ data }) => {
165
160
) ,
166
161
0 ,
167
162
) ) ;
168
- } , [ allSectionsForPrevRun ] ) ;
163
+ } , [ allSections ] ) ;
169
164
170
165
const activeFilters = Object . keys ( filters ) . filter ( key => filters [ key ] ) ;
171
166
const [ filterBy , {
172
167
add, remove, set, clear,
173
168
} ] = useCheckboxSetValues ( activeFilters ) ;
174
169
175
170
useEffect ( ( ) => {
176
- setOpenStates ( allSectionsForBrokenLinks ? allSectionsForBrokenLinks . map ( ( ) => false ) : [ ] ) ;
177
- setPrevRunOpenStates ( allSectionsForPrevRun ? allSectionsForPrevRun . map ( ( ) => false ) : [ ] ) ;
178
- } , [ allSectionsForBrokenLinks , allSectionsForPrevRun ] ) ;
171
+ setOpenStates ( allSections ? allSections . map ( ( ) => false ) : [ ] ) ;
172
+ setPrevRunOpenStates ( allSections ? allSections . map ( ( ) => false ) : [ ] ) ;
173
+ } , [ allSections ] ) ;
179
174
180
175
if ( isDataEmpty ( data ) ) {
181
176
return < InfoCard text = { intl . formatMessage ( messages . noDataCard ) } /> ;
@@ -193,7 +188,7 @@ const ScanResults: FC<Props> = ({ data }) => {
193
188
] ;
194
189
// Only show sections that have at least one unit with a visible link (not just previousRunLinks)
195
190
const shouldSectionRender = ( sectionIndex : number ) : boolean => {
196
- const section = allSectionsForBrokenLinks [ sectionIndex ] ;
191
+ const section = allSections [ sectionIndex ] ;
197
192
const hasVisibleUnit = section . subsections . some (
198
193
( subsection ) => subsection . units . some ( ( unit ) => unit . blocks . some ( ( block ) => {
199
194
const hasBroken = block . brokenLinks ?. length > 0 ;
@@ -232,7 +227,7 @@ const ScanResults: FC<Props> = ({ data }) => {
232
227
233
228
const findNextVisibleSection = ( currentIndex : number ) : number => {
234
229
let nextIndex = currentIndex + 1 ;
235
- while ( nextIndex < allSectionsForBrokenLinks . length ) {
230
+ while ( nextIndex < allSections . length ) {
236
231
if ( shouldSectionRender ( nextIndex ) ) {
237
232
return nextIndex ;
238
233
}
@@ -311,8 +306,8 @@ const ScanResults: FC<Props> = ({ data }) => {
311
306
312
307
{ ( ( ) => {
313
308
// Find all visible sections
314
- const visibleSections = allSectionsForBrokenLinks && allSectionsForBrokenLinks . length > 0
315
- ? allSectionsForBrokenLinks
309
+ const visibleSections = allSections && allSections . length > 0
310
+ ? allSections
316
311
. map ( ( _ , index ) => ( shouldSectionRender ( index ) ? index : - 1 ) )
317
312
. filter ( idx => idx !== - 1 )
318
313
: [ ] ;
@@ -323,7 +318,7 @@ const ScanResults: FC<Props> = ({ data }) => {
323
318
</ div >
324
319
) ;
325
320
}
326
- return allSectionsForBrokenLinks . map ( ( section , index ) => {
321
+ return allSections . map ( ( section , index ) => {
327
322
if ( ! shouldSectionRender ( index ) ) {
328
323
return null ;
329
324
}
@@ -336,7 +331,7 @@ const ScanResults: FC<Props> = ({ data }) => {
336
331
const prevVisibleIndex = findPreviousVisibleSection ( index ) ;
337
332
return prevVisibleIndex >= 0 && openStates [ prevVisibleIndex ] ;
338
333
} ) ( ) : true }
339
- hasNextAndIsOpen = { index < allSectionsForBrokenLinks . length - 1 ? ( ( ) => {
334
+ hasNextAndIsOpen = { index < allSections . length - 1 ? ( ( ) => {
340
335
const nextVisibleIndex = findNextVisibleSection ( index ) ;
341
336
return nextVisibleIndex >= 1 && openStates [ nextVisibleIndex ] ;
342
337
} ) ( ) : true }
@@ -388,11 +383,11 @@ const ScanResults: FC<Props> = ({ data }) => {
388
383
</ div >
389
384
390
385
{ waffleFlags . enableCourseOptimizerCheckPrevRunLinks
391
- && allSectionsForPrevRun
392
- && allSectionsForPrevRun . length > 0
386
+ && allSections
387
+ && allSections . length > 0
393
388
&& hasPreviousRunLinks && ( ( ) => {
394
389
// Filter out sections/subsections/units that have no previous run links
395
- const filteredSections = allSectionsForPrevRun . map ( ( section ) => {
390
+ const filteredSections = allSections . map ( ( section ) => {
396
391
// Filter subsections
397
392
const filteredSubsections = section . subsections . map ( subsection => {
398
393
// Filter units
0 commit comments