@@ -7,7 +7,7 @@ import {defineMessages, injectIntl, intlShape} from 'react-intl';
77import analytics from '../lib/analytics' ;
88import log from '../lib/log' ;
99import { setProjectTitle } from '../reducers/project-title' ;
10- import { onLoadedProject , onProjectUploadStarted } from '../reducers/project-state' ;
10+ import { LoadingStates , onLoadedProject , onProjectUploadStarted } from '../reducers/project-state' ;
1111
1212import {
1313 openLoadingProject ,
@@ -61,15 +61,15 @@ class SBFileUploader extends React.Component {
6161 action : 'Import Project File' ,
6262 nonInteraction : true
6363 } ) ;
64- this . props . onLoadingFinished ( ) ;
64+ this . props . onLoadingFinished ( this . props . loadingState ) ;
6565 // Reset the file input after project is loaded
6666 // This is necessary in case the user wants to reload a project
6767 thisFileInput . value = null ;
6868 } )
6969 . catch ( error => {
7070 log . warn ( error ) ;
7171 alert ( this . props . intl . formatMessage ( messages . loadError ) ) ; // eslint-disable-line no-alert
72- this . props . onLoadingFinished ( ) ;
72+ this . props . onLoadingFinished ( this . props . loadingState ) ;
7373 // Reset the file input after project is loaded
7474 // This is necessary in case the user wants to reload a project
7575 thisFileInput . value = null ;
@@ -82,10 +82,7 @@ class SBFileUploader extends React.Component {
8282 const matches = thisFileInput . files [ 0 ] . name . match ( / ^ ( .* ) \. s b 3 $ / ) ;
8383 if ( matches ) {
8484 const truncatedProjectTitle = matches [ 1 ] . substring ( 0 , 100 ) ;
85- this . props . onSetReduxProjectTitle ( truncatedProjectTitle ) ;
86- if ( this . props . onUpdateProjectTitle ) {
87- this . props . onUpdateProjectTitle ( truncatedProjectTitle ) ;
88- }
85+ this . props . onSetProjectTitle ( truncatedProjectTitle ) ;
8986 }
9087 }
9188 }
@@ -116,24 +113,25 @@ class SBFileUploader extends React.Component {
116113SBFileUploader . propTypes = {
117114 children : PropTypes . func ,
118115 intl : intlShape . isRequired ,
116+ loadingState : PropTypes . oneOf ( LoadingStates ) ,
119117 onLoadingFinished : PropTypes . func ,
120118 onLoadingStarted : PropTypes . func ,
121- onSetReduxProjectTitle : PropTypes . func ,
122- onUpdateProjectTitle : PropTypes . func ,
119+ onSetProjectTitle : PropTypes . func ,
123120 vm : PropTypes . shape ( {
124121 loadProject : PropTypes . func
125122 } )
126123} ;
127124const mapStateToProps = state => ( {
125+ loadingState : state . scratchGui . projectState . loadingState ,
128126 vm : state . scratchGui . vm
129127} ) ;
130128
131129const mapDispatchToProps = dispatch => ( {
132- onLoadingFinished : ( ) => {
133- dispatch ( onLoadedProject ( ) ) ;
130+ onLoadingFinished : loadingState => {
131+ dispatch ( onLoadedProject ( loadingState ) ) ;
134132 dispatch ( closeLoadingProject ( ) ) ;
135133 } ,
136- onSetReduxProjectTitle : title => dispatch ( setProjectTitle ( title ) ) ,
134+ onSetProjectTitle : title => dispatch ( setProjectTitle ( title ) ) ,
137135 onLoadingStarted : ( ) => {
138136 dispatch ( openLoadingProject ( ) ) ;
139137 dispatch ( onProjectUploadStarted ( ) ) ;
0 commit comments