diff --git a/src/components/menu-bar/menu-bar.jsx b/src/components/menu-bar/menu-bar.jsx index e33868b96bb0ad76fbefdd993badcd603c7fe64b..f046710e0f17ad4f24304e613373b6f40a4da604 100644 --- a/src/components/menu-bar/menu-bar.jsx +++ b/src/components/menu-bar/menu-bar.jsx @@ -333,7 +333,7 @@ class MenuBar extends React.Component { )} </MenuSection> <MenuSection> - <SBFileUploader> + <SBFileUploader onUpdateProjectTitle={this.props.onUpdateProjectTitle}> {(renderFileInput, loadProject) => ( <MenuItem onClick={loadProject} diff --git a/src/containers/sb-file-uploader.jsx b/src/containers/sb-file-uploader.jsx index a5d8c99a70078a94be55d7570087a73c80bfe636..5cffb05ad3b1cc1e8d219d7736b1c4b3c58c5009 100644 --- a/src/containers/sb-file-uploader.jsx +++ b/src/containers/sb-file-uploader.jsx @@ -79,10 +79,13 @@ class SBFileUploader extends React.Component { reader.readAsArrayBuffer(thisFileInput.files[0]); // extract the title from the file and set it as current project title if (thisFileInput.files[0].name) { - const matches = thisFileInput.files[0].name.match(/^(.*)\.sb3$/); + const matches = thisFileInput.files[0].name.match(/^(.*?)(\.sb[23]?)?$/); if (matches) { const truncatedProjectTitle = matches[1].substring(0, 100); - this.props.onSetProjectTitle(truncatedProjectTitle); + this.props.onSetReduxProjectTitle(truncatedProjectTitle); + if (this.props.onUpdateProjectTitle) { + this.props.onUpdateProjectTitle(truncatedProjectTitle); + } } } } @@ -116,7 +119,8 @@ SBFileUploader.propTypes = { loadingState: PropTypes.oneOf(LoadingStates), onLoadingFinished: PropTypes.func, onLoadingStarted: PropTypes.func, - onSetProjectTitle: PropTypes.func, + onSetReduxProjectTitle: PropTypes.func, + onUpdateProjectTitle: PropTypes.func, vm: PropTypes.shape({ loadProject: PropTypes.func }) @@ -131,7 +135,7 @@ const mapDispatchToProps = dispatch => ({ dispatch(onLoadedProject(loadingState)); dispatch(closeLoadingProject()); }, - onSetProjectTitle: title => dispatch(setProjectTitle(title)), + onSetReduxProjectTitle: title => dispatch(setProjectTitle(title)), onLoadingStarted: () => { dispatch(openLoadingProject()); dispatch(onProjectUploadStarted());