@@ -64,10 +64,10 @@ const getNatOptions = (username = undefined) =>
64
64
const MobileIDEView = ( props ) => {
65
65
const {
66
66
preferences, ide, editorAccessibility, project, updateLintMessage, clearLintMessage,
67
- selectedFile, updateFileContent, files, user,
67
+ selectedFile, updateFileContent, files, user, params ,
68
68
closeEditorOptions, showEditorOptions,
69
69
startRefreshSketch, stopSketch, expandSidebar, collapseSidebar, clearConsole, console,
70
- showRuntimeErrorWarning, hideRuntimeErrorWarning, startSketch
70
+ showRuntimeErrorWarning, hideRuntimeErrorWarning, startSketch, getProject , clearPersistedState
71
71
} = props ;
72
72
73
73
const [ tmController , setTmController ] = useState ( null ) ; // eslint-disable-line
@@ -79,16 +79,22 @@ const MobileIDEView = (props) => {
79
79
align = "right"
80
80
/> ) ;
81
81
82
+ // Force state reset
83
+ useEffect ( clearPersistedState , [ ] ) ;
84
+ useEffect ( stopSketch , [ ] ) ;
85
+ useEffect ( ( ) => getProject ( params . project_id ) , [ ] ) ;
86
+
82
87
// Load Project
88
+ const [ currentProjectID , setCurrentProjectID ] = useState ( null ) ;
83
89
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 ] ) ;
89
97
90
- // getProject(nextProps.params.project_id);
91
- } , [ ] ) ;
92
98
93
99
return (
94
100
< Screen fullscreen >
@@ -260,6 +266,10 @@ MobileIDEView.propTypes = {
260
266
id : PropTypes . string ,
261
267
username : PropTypes . string ,
262
268
} ) . isRequired ,
269
+
270
+ getProject : PropTypes . func . isRequired ,
271
+ clearPersistedState : PropTypes . func . isRequired ,
272
+ params : PropTypes . shape ( { project_id : PropTypes . string } ) . isRequired ,
263
273
} ;
264
274
265
275
function mapStateToProps ( state ) {
0 commit comments