Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Color Changing Bug w/ Duplicate Courses #719

Merged
merged 11 commits into from
Oct 27, 2023
Merged

fix: Color Changing Bug w/ Duplicate Courses #719

merged 11 commits into from
Oct 27, 2023

Conversation

KevinWu098
Copy link
Member

@KevinWu098 KevinWu098 commented Oct 3, 2023

Summary

screen-recorder-sat-sep-30-2023-15-39-24.1.webm

As shown above (and in #716), changing colors of a course event fails if the same course event exists in a schedule that is lower in index than the one currently being changed.

The reason for this is that getExistingCourse (shown below) only returned the reference of a singular course that matched the given params. This meant that courses (which matched the params) in other schedules would not have their colors changed.

    /**
     * @return Reference of a course that matches the params
     */
    getExistingCourse(sectionCode: string, term: string) {
        for (const course of this.getAllCourses()) {
            if (course.section.sectionCode === sectionCode && term === course.term) {
                return course;   // <----- the problem
            }
        }
        return undefined;
    }

TL;DR Color Picker and Courses will now correctly update their colors (without affecting other schedules and courses)

Test Plan

  1. Create at least two schedules which contain the same course
  2. Attempt to change the color on each. Success will be defined by steps 3-6
  3. The color of the course in the Calendar should update
  4. The color of the course in the Search pane should update
  5. The color of the course in the Added pane should update
  6. The updated colors should save and be loaded in correctly

Issues

Closes #716

@KevinWu098 KevinWu098 marked this pull request as ready for review October 15, 2023 04:02
@github-actions github-actions bot requested a review from EricPedley October 15, 2023 04:02
@KevinWu098 KevinWu098 changed the title [WIP] Fix Color Changing Bug w/ Duplicate Courses fix: Color Changing Bug w/ Duplicate Courses Oct 15, 2023
Copy link
Member

@EricPedley EricPedley left a comment

Choose a reason for hiding this comment

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

Results look good, just a few comments about the implementation

@KevinWu098 KevinWu098 requested a review from EricPedley October 19, 2023 17:07
Copy link
Member

@EricPedley EricPedley left a comment

Choose a reason for hiding this comment

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

🚢🚢🚢

@EricPedley EricPedley merged commit 3ac6df7 into main Oct 27, 2023
6 checks passed
@EricPedley EricPedley deleted the fix-color-bug branch October 27, 2023 02:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Duplicate Courses in Multiple Schedules Breaks Color Picker
2 participants