@@ -64,10 +64,10 @@ const getNatOptions = (username = undefined) =>
6464const MobileIDEView = ( props ) => {
6565 const {
6666 preferences, ide, editorAccessibility, project, updateLintMessage, clearLintMessage,
67- selectedFile, updateFileContent, files, user,
67+ selectedFile, updateFileContent, files, user, params ,
6868 closeEditorOptions, showEditorOptions,
6969 startRefreshSketch, stopSketch, expandSidebar, collapseSidebar, clearConsole, console,
70- showRuntimeErrorWarning, hideRuntimeErrorWarning, startSketch
70+ showRuntimeErrorWarning, hideRuntimeErrorWarning, startSketch, getProject , clearPersistedState
7171 } = props ;
7272
7373 const [ tmController , setTmController ] = useState ( null ) ; // eslint-disable-line
@@ -79,16 +79,22 @@ const MobileIDEView = (props) => {
7979 align = "right"
8080 /> ) ;
8181
82+ // Force state reset
83+ useEffect ( clearPersistedState , [ ] ) ;
84+ useEffect ( stopSketch , [ ] ) ;
85+ useEffect ( ( ) => getProject ( params . project_id ) , [ ] ) ;
86+
8287 // Load Project
88+ const [ currentProjectID , setCurrentProjectID ] = useState ( null ) ;
8389 useEffect ( ( ) => {
84- // const { project_id } = params;
85- // const oldproject_id = '';
86-
87- // if (nextProps.params.project_id && !oldproject_id)
88- // if (nextProps.params.project_id !== nextProps.project.id)
90+ if ( params . project_id && ! currentProjectID ) {
91+ if ( params . project_id !== project . id ) {
92+ getProject ( params . project_id ) ;
93+ }
94+ }
95+ setCurrentProjectID ( params . project_id ) ;
96+ } , [ params , project ] ) ;
8997
90- // getProject(nextProps.params.project_id);
91- } , [ ] ) ;
9298
9399 return (
94100 < Screen fullscreen >
@@ -260,6 +266,10 @@ MobileIDEView.propTypes = {
260266 id : PropTypes . string ,
261267 username : PropTypes . string ,
262268 } ) . isRequired ,
269+
270+ getProject : PropTypes . func . isRequired ,
271+ clearPersistedState : PropTypes . func . isRequired ,
272+ params : PropTypes . shape ( { project_id : PropTypes . string } ) . isRequired ,
263273} ;
264274
265275function mapStateToProps ( state ) {
0 commit comments