Skip to content
Snippets Groups Projects
Commit 641cfd05 authored by Ben Wheeler's avatar Ben Wheeler
Browse files

don't set redux project title directly from sb uploader; only extract title...

don't set redux project title directly from sb uploader; only extract title from .sb2 and .sb3 filenames
parent 33f5aaf3
Branches
Tags
No related merge requests found
......@@ -368,6 +368,7 @@ GUIComponent.defaultProps = {
canSave: false,
canSaveAsCopy: false,
canShare: false,
onUpdateProjectTitle: () => {},
stageSizeMode: STAGE_SIZE_MODES.large
};
......
......@@ -6,7 +6,6 @@ import {defineMessages, injectIntl, intlShape} from 'react-intl';
import analytics from '../lib/analytics';
import log from '../lib/log';
import {setProjectTitle} from '../reducers/project-title';
import {LoadingStates, onLoadedProject, onProjectUploadStarted} from '../reducers/project-state';
import {
......@@ -79,13 +78,11 @@ 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(/^(.*?)(\.sb[23]?)?$/);
// only parse title from files like "filename.sb2" or "filename.sb3"
const matches = thisFileInput.files[0].name.match(/^(.*)\.sb[23]$/);
if (matches) {
const truncatedProjectTitle = matches[1].substring(0, 100);
this.props.onSetReduxProjectTitle(truncatedProjectTitle);
if (this.props.onUpdateProjectTitle) {
this.props.onUpdateProjectTitle(truncatedProjectTitle);
}
this.props.onUpdateProjectTitle(truncatedProjectTitle);
}
}
}
......@@ -119,7 +116,6 @@ SBFileUploader.propTypes = {
loadingState: PropTypes.oneOf(LoadingStates),
onLoadingFinished: PropTypes.func,
onLoadingStarted: PropTypes.func,
onSetReduxProjectTitle: PropTypes.func,
onUpdateProjectTitle: PropTypes.func,
vm: PropTypes.shape({
loadProject: PropTypes.func
......@@ -135,7 +131,6 @@ const mapDispatchToProps = dispatch => ({
dispatch(onLoadedProject(loadingState));
dispatch(closeLoadingProject());
},
onSetReduxProjectTitle: title => dispatch(setProjectTitle(title)),
onLoadingStarted: () => {
dispatch(openLoadingProject());
dispatch(onProjectUploadStarted());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment