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

Fixes deleting mostRecentProgram in ConfirmDeleteModal #289

Merged
merged 2 commits into from
Jun 1, 2020

Conversation

mattxwang
Copy link
Collaborator

@mattxwang mattxwang commented May 30, 2020

This PR fixes the nasty bug that corrupts our internal Redux state when you delete what happens to be the mostRecentProgram. We do this by adding a check when we delete the sketch: if the sketch's ID matches mostRecentProgram, we then update it with setMostRecentProgram with either the first item in the new programs list.

As a minor impl. note, we don't have to worry about a situation with only one sketch, as the editor component itself handles situations with zero sketches (and doesn't access mostRecentProgram). So, this fix doesn't change the existing bevhaiour in that scenario.

If we add more areas where we delete sketches (i.e. in the classes feature), we should probably make some action that does something to the effect of deleteSketchAndUpdate that handles all of these things at once, which reduces our cognitive load!

As an aside, we should probably check that mostRecentProgram is valid whenever we access it, and/or refactor many of its uses (as we've discussed, the editor depends too much on it).

replaces mostRecentProgram with another program, if applicable.
@mattxwang mattxwang added the bug Something isn't working label May 30, 2020
@jamieliu386
Copy link
Contributor

Hey Matt, looks good overall! However, I was able to reproduce the same bug in the edge case where I only had two sketches and deleted whichever one was the most recent program.

@mattxwang
Copy link
Collaborator Author

Hey Matt, looks good overall! However, I was able to reproduce the same bug in the edge case where I only had two sketches and deleted whichever one was the most recent program.

Oop that seems bad, I'll take a look!

@mattxwang
Copy link
Collaborator Author

Okay, think I fixed it, @jamieliu386 can you take a look again?

Copy link
Contributor

@krashanoff krashanoff left a comment

Choose a reason for hiding this comment

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

I just tested the same bug as Jamie on my end and things are looking fixed. We can wait to hear from her but things are looking AOK over here. Thanks for handling this Matt!

@jamieliu386
Copy link
Contributor

Hey, sorry for the late review. Looks good on my end, too!

@krashanoff krashanoff merged commit c17e02f into master Jun 1, 2020
@krashanoff krashanoff deleted the fix-delete-sketch-corrupted-mrp branch June 1, 2020 02:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants