Skip to content

Commit 96367c8

Browse files
committed
debounce lessonCompleted & lastLesson events from FCC
1 parent 70d0116 commit 96367c8

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src-ts/tools/learn/free-code-camp/FreeCodeCamp.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import { FccFrame } from './fcc-frame'
4545
import { FccSidebar } from './fcc-sidebar'
4646
import { TitleNav } from './title-nav'
4747
import styles from './FreeCodeCamp.module.scss'
48+
import { debounce } from 'lodash'
4849

4950
const FreeCodeCamp: FC<{}> = () => {
5051

@@ -211,7 +212,7 @@ const FreeCodeCamp: FC<{}> = () => {
211212
profile?.userId,
212213
])
213214

214-
const handleFccLessonComplete: (challengeUuid: string) => void = useCallback((challengeUuid: string) => {
215+
const handleFccLessonComplete: (challengeUuid: string) => void = useCallback(debounce((challengeUuid: string) => {
215216

216217
const currentLesson: { [key: string]: string } = {
217218
lesson: lessonParam,
@@ -239,7 +240,7 @@ const FreeCodeCamp: FC<{}> = () => {
239240

240241
})
241242
// eslint-disable-next-line react-hooks/exhaustive-deps
242-
}, [
243+
}, 30), [
243244
certificateProgress,
244245
lessonParam,
245246
moduleParam,
@@ -280,7 +281,7 @@ const FreeCodeCamp: FC<{}> = () => {
280281
* Handle the navigation away from the last step of the course in the FCC frame
281282
* @returns
282283
*/
283-
const handleFccLastLessonNavigation: () => void = useCallback(() => {
284+
const handleFccLastLessonNavigation: () => void = useCallback(debounce(() => {
284285

285286
if (!certificateProgress) {
286287
return
@@ -326,7 +327,7 @@ const FreeCodeCamp: FC<{}> = () => {
326327

327328
navigate(nextLessonPath)
328329
// eslint-disable-next-line react-hooks/exhaustive-deps
329-
}, [
330+
}, 30), [
330331
certificateProgress,
331332
certificationParam,
332333
courseData?.modules,

0 commit comments

Comments
 (0)