Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,17 @@
(cls) => cls.id === course.picked_class_id
)]
}

const courseFilteredTeachers = course.filteredTeachers

const availableClasses = classesCombinations.filter((class_info) => {
return uniqueClasses.includes(class_info.class_info.name)
if (!uniqueClasses.includes(class_info.class_info.name)) return false
if (!courseFilteredTeachers || courseFilteredTeachers.length === 0) return true
return class_info.class_info.slots.some((slot) =>
slot.professors.length === 0 ||
slot.professors.some((prof) => courseFilteredTeachers.includes(prof.id))
)
})

return availableClasses
.filter((class_info) => class_info.course_info.id === course.course_id)
.map((class_info) => class_info.class_info)
Expand Down Expand Up @@ -238,6 +244,13 @@
// Updating locked courses
const newLockedCourses = selected?.filter((course) => course.locked)
.map((course) => course.course_id)

const newFilteredTeachers = selected?.map((course) =>

Check failure on line 248 in src/components/planner/sidebar/selectedOptionController/RandomFill.tsx

View workflow job for this annotation

GitHub Actions / Lint (21.x)

'newFilteredTeachers' is assigned a value but never used
(course.filteredTeachers ?? []).join(',')).join('|')

const prevFilteredTeachers = courseOptions?.map((course) =>

Check failure on line 251 in src/components/planner/sidebar/selectedOptionController/RandomFill.tsx

View workflow job for this annotation

GitHub Actions / Lint (21.x)

'prevFilteredTeachers' is assigned a value but never used
(course.filteredTeachers ?? []).join(',')).join('|')

// Only update if locked courses changed
if (newLockedCourses?.join() !== lockedCourses?.join()) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

newFilteredTeachers and prevFilteredTeachers are computed here but never used — the condition only checks locked courses, so the generator is never reset when teacher filters change. This contradicts the PR description which lists it as one of the two goals.

Suggested change
if (newLockedCourses?.join() !== lockedCourses?.join()) {
if (newLockedCourses?.join() !== lockedCourses?.join() || newFilteredTeachers !== prevFilteredTeachers) {

One thing worth double-checking before merging: this comparison assumes courseOptions holds the previous filter state (one render behind) while selected holds the new one. If courseOptions is always current, the comparison will always be equal and the reset will never fire even after this fix. Can you confirm courseOptions is stale state here?

setLockedCourses(newLockedCourses)
Expand Down
Loading