don't set redux project title directly from sb uploader; only extract title from .sb2 and .sb3 filenames

This commit is contained in:
Ben Wheeler committed 2018-10-17 15:50:54 -04:00
1 parent 33f5aaf34b
commit 641cfd058b
2 files changed
+4 -8

No files matched your search

+1
View File
@@ -368,6 +368,7 @@ GUIComponent.defaultProps = {
canSave: false,
canSaveAsCopy: false,
canShare: false,
onUpdateProjectTitle: () => {},
stageSizeMode: STAGE_SIZE_MODES.large
};
+3 -8
View File
@@ -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());