Skip to content

Commit

Permalink
URGENT fix: prevent non-course object from being traversed
Browse files Browse the repository at this point in the history
  • Loading branch information
ImJustChew committed Aug 19, 2024
1 parent a7ddf70 commit 8d66b61
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/hooks/contexts/useUserTimetable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,14 @@ const useUserTimetableProvider = (loadCourse = true) => {

const coursesCopy = { ...courses };

// Check and confirm if coursesCopy is traversable
if (Object.keys(coursesCopy).length === 0) return;
if (Object.keys(coursesCopy).find((sem) => sem.length !== 5)) return;
if (
Object.keys(coursesCopy).find((sem) => !Array.isArray(coursesCopy[sem]))
)
return;

Object.keys(coursesCopy).forEach((sem) => {
(coursesCopy[sem] ?? []).forEach((courseID, i) => {
newColorMap[courseID] = newColors[i % newColors.length];
Expand Down

0 comments on commit 8d66b61

Please sign in to comment.