From 539976193e4cfd6e334c6a17b00fb22f6902cae6 Mon Sep 17 00:00:00 2001
From: Ben Wheeler <wheeler.benjamin@gmail.com>
Date: Wed, 24 Oct 2018 16:43:28 -0400
Subject: [PATCH] got rid of uses of undefined

---
 src/lib/project-saver-hoc.jsx | 31 ++++++++++++++++---------------
 1 file changed, 16 insertions(+), 15 deletions(-)

diff --git a/src/lib/project-saver-hoc.jsx b/src/lib/project-saver-hoc.jsx
index 3c583d211..dd98c8e19 100644
--- a/src/lib/project-saver-hoc.jsx
+++ b/src/lib/project-saver-hoc.jsx
@@ -44,7 +44,7 @@ const ProjectSaverHOC = function (WrappedComponent) {
             }
             // TODO: distinguish between creating new, remixing, and saving as a copy
             if (this.props.isCreatingNew && !prevProps.isCreatingNew) {
-                this.storeProject()
+                this.storeProject(null)
                     .then(response => {
                         this.props.onCreatedProject(response.id.toString(), this.props.loadingState);
                     })
@@ -53,10 +53,9 @@ const ProjectSaverHOC = function (WrappedComponent) {
                     });
             }
             if (this.props.isCreatingCopy && !prevProps.isCreatingCopy) {
-                this.storeProject(undefined, {
+                this.storeProject(null, {
                     original_id: this.props.reduxProjectId,
-                    is_copy: 1,
-                    title: encodeURIComponent(this.props.reduxProjectTitle)
+                    is_copy: 1
                 })
                     .then(response => {
                         this.props.onCreatedProject(response.id.toString(), this.props.loadingState);
@@ -66,10 +65,9 @@ const ProjectSaverHOC = function (WrappedComponent) {
                     });
             }
             if (this.props.isRemixing && !prevProps.isRemixing) {
-                this.storeProject(undefined, {
+                this.storeProject(null, {
                     original_id: this.props.reduxProjectId,
-                    is_remix: 1,
-                    title: encodeURIComponent(this.props.reduxProjectTitle)
+                    is_remix: 1
                 })
                     .then(response => {
                         this.props.onCreatedProject(response.id.toString(), this.props.loadingState);
@@ -98,10 +96,11 @@ const ProjectSaverHOC = function (WrappedComponent) {
         }
         /**
          * storeProject:
-         * @param  {number|string|undefined} projectId defined value causes PUT/update; undefined causes POST/create
-         * @return {Promise} resolves with json object containing project's existing or new id
+         * @param  {number|string|undefined} projectId - defined value will PUT/update; undefined/null will POST/create
+         * @return {Promise} - resolves with json object containing project's existing or new id
+         * @param {?object} urlParams - object of params to add to querystring
          */
-        storeProject (projectId, urlOptions) {
+        storeProject (projectId, urlParams) {
             return this.props.vm.saveProjectSb3()
                 .then(content => {
                     const assetType = storage.AssetType.Project;
@@ -115,14 +114,16 @@ const ProjectSaverHOC = function (WrappedComponent) {
                         dataFormat,
                         body,
                         projectId,
-                        urlOptions
+                        urlParams
                     );
                 });
         }
         render () {
             const {
                 /* eslint-disable no-unused-vars */
-                isCreating: isCreatingProp,
+                isCreatingCopy: isCreatingCopyProp,
+                isCreatingNew: isCreatingNewProp,
+                isRemixing: isRemixingProp,
                 isShowingWithId: isShowingWithIdProp,
                 isShowingWithoutId: isShowingWithoutIdProp,
                 isUpdating: isUpdatingProp,
@@ -146,7 +147,9 @@ const ProjectSaverHOC = function (WrappedComponent) {
     ProjectSaverComponent.propTypes = {
         canCreateNew: PropTypes.bool,
         canSave: PropTypes.bool,
-        isCreating: PropTypes.bool,
+        isCreatingCopy: PropTypes.bool,
+        isCreatingNew: PropTypes.bool,
+        isRemixing: PropTypes.bool,
         isShowingWithId: PropTypes.bool,
         isShowingWithoutId: PropTypes.bool,
         isUpdating: PropTypes.bool,
@@ -157,7 +160,6 @@ const ProjectSaverHOC = function (WrappedComponent) {
         onUpdateProject: PropTypes.func,
         onUpdatedProject: PropTypes.func,
         reduxProjectId: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
-        reduxProjectTitle: PropTypes.string,
         vm: PropTypes.instanceOf(VM).isRequired
     };
     const mapStateToProps = state => {
@@ -171,7 +173,6 @@ const ProjectSaverHOC = function (WrappedComponent) {
             isUpdating: getIsUpdating(loadingState),
             loadingState: loadingState,
             reduxProjectId: state.scratchGui.projectState.projectId,
-            reduxProjectTitle: state.scratchGui.projectTitle,
             vm: state.scratchGui.vm
         };
     };
-- 
GitLab