-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Fixes #681 - File name update triggers editor change detection #1372
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 #681 - File name update triggers editor change detection #1372
Conversation
… into fix/rename-file-set-unsaved
🎉 Thanks for opening this pull request! Please check out our contributing guidelines if you haven't already. |
Thanks for working on this! While this approach works, I'm not sure it's the best one. I think it can be super confusing when to store the state in React vs. Redux, and this is a case in which I think it makes sense to store it in React. I would suggest taking a similar approach, but storing |
@catarak Agreed, thanks for the input. I followed your suggestion, and it's a bit clearer now |
I chose to write a quick test for that filename check, hope that's ok |
…tional best practices
…ing to folder if not authenticated
I couldn't help myself and ended up hijacking this PR 🤦 Ended up with a great refactor though! |
Problem (#681)
Editor would not detect filename changes as project changes. This is a minor issue since usually filenames will be referred to by other files, which require changing said files, therefore triggering a change in the project. Still, it's a nice detail to have.
Solution
Detecting these changes require comparing the original filename to the new one, so a new
updatedName
field was created in thefiles
reducer. TheupdatedFileName
action should detect if they are different before triggering changes, requiring the ability to dispatch more than one action at once, so it was refactored to a thunk. Finally, the saveProject action must commit these name changes, and clear theirupdatedNames
, so this was added right before sending the request.I have verified that this pull request:
npm run lint
)Fixes #123