-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Order files alphabetically in sidebar and nested folders. #1530
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
Order files alphabetically in sidebar and nested folders. #1530
Conversation
This commit solves issue #704. I added a function to get sorted children of the parent file when ever a file is created of renamed. This function is only called on the parent of the file that is create or renamed.
🎉 Thanks for opening this pull request! Please check out our contributing guidelines if you haven't already. |
client/modules/IDE/reducers/files.js
Outdated
@@ -138,33 +144,48 @@ const files = (state, action) => { | |||
return initialState(); | |||
case ActionTypes.CREATE_FILE: // eslint-disable-line | |||
{ | |||
const newState = state.map((file) => { | |||
let newState = state.map((file) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The body of this case statement is pretty long, and I wonder if it could be refactored into smaller functions. I know this is also true in other case statements in this file that you didn't work on, but I think this is an opportunity to do a little cleaning up 😄
This is working for me! My only suggestion is breaking up the code into some smaller functions so that the code is easier to read. |
Is this fine?? |
client/modules/IDE/reducers/files.js
Outdated
@@ -116,6 +116,26 @@ function sortedChildrenId(state, children) { | |||
return childrenArray.map(child => child.id); | |||
} | |||
|
|||
function udpateParent(state, action) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for doing the refactor! One small thing—I think you meant "update"
here rather than "udpate"
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh sorry wait just updating
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no worries!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done!!
Testing this again, I also noticed that the sorting works for new sketches, or while editing a sketch, but not when opening an existing sketch (e.g. when you load http://localhost:8000/p5/sketches/Hello_P5:_song, you'll need to run |
Thanks for pointing it out! This commit will fix the problem |
Working great—thanks for working on this! |
No problem, it really feels great after your first open-source contribution!! |
Welcome to contributing to open source and to p5.js! |
This PR solves issue #704. I added a function to get sorted children of the parent file whenever a file is created or renamed. This function is only called on the parent of the file that is created or renamed.
Fixes #704
I have verified that this pull request:
npm run lint
)Fixes #123