-
-
Notifications
You must be signed in to change notification settings - Fork 49
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
Add defaultName for saving .js or .zip #178
Conversation
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 the PR! Can you remove the code that changes the script name (or change it in a way that it actually takes the default name)
Always great to see people contributing!
export default (code, fileName) => { | ||
fileName = fileName ?? 'replicad-script' | ||
export default async (code, fileName) => { | ||
fileName = fileName |
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.
Are you sure this does something? I feel like it always take the name of the first export
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.
const shapeName =
store.currentMesh.length === 1 ? store.currentMesh[0]?.name : null;
return downloadCode(store.code.current, shapeName);
It'll use the shape name if there is only 1 shape and only if it has a name, then it will use the defaultName
then it will fallback to replicad-script
.
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.
Would defaultName ?? shapeName ?? 'replicad-script'
be a better order?
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.
Yeah, I think this would be a better order (as all shapes get a name by default).
Thanks! I will do a couple of changes on my end to support the case where there is only one shape. |
Allows exporting
defaultName
which will be used when saving.js
or.zip
filesFixes #177