🚧 write hooks for mounting MobileIDEView component

This commit is contained in:
ghalestrilo 2020-08-05 15:27:22 -03:00
parent dd431a07df
commit f2e8d40861

View file

@ -64,10 +64,10 @@ const getNatOptions = (username = undefined) =>
const MobileIDEView = (props) => { const MobileIDEView = (props) => {
const { const {
preferences, ide, editorAccessibility, project, updateLintMessage, clearLintMessage, preferences, ide, editorAccessibility, project, updateLintMessage, clearLintMessage,
selectedFile, updateFileContent, files, user, selectedFile, updateFileContent, files, user, params,
closeEditorOptions, showEditorOptions, closeEditorOptions, showEditorOptions,
startRefreshSketch, stopSketch, expandSidebar, collapseSidebar, clearConsole, console, startRefreshSketch, stopSketch, expandSidebar, collapseSidebar, clearConsole, console,
showRuntimeErrorWarning, hideRuntimeErrorWarning, startSketch showRuntimeErrorWarning, hideRuntimeErrorWarning, startSketch, getProject, clearPersistedState
} = props; } = props;
const [tmController, setTmController] = useState(null); // eslint-disable-line const [tmController, setTmController] = useState(null); // eslint-disable-line
@ -79,16 +79,22 @@ const MobileIDEView = (props) => {
align="right" align="right"
/>); />);
// Force state reset
useEffect(clearPersistedState, []);
useEffect(stopSketch, []);
useEffect(() => getProject(params.project_id), []);
// Load Project // Load Project
const [currentProjectID, setCurrentProjectID] = useState(null);
useEffect(() => { useEffect(() => {
// const { project_id } = params; if (params.project_id && !currentProjectID) {
// const oldproject_id = ''; if (params.project_id !== project.id) {
getProject(params.project_id);
}
}
setCurrentProjectID(params.project_id);
}, [params, project]);
// if (nextProps.params.project_id && !oldproject_id)
// if (nextProps.params.project_id !== nextProps.project.id)
// getProject(nextProps.params.project_id);
}, []);
return ( return (
<Screen fullscreen> <Screen fullscreen>
@ -260,6 +266,10 @@ MobileIDEView.propTypes = {
id: PropTypes.string, id: PropTypes.string,
username: PropTypes.string, username: PropTypes.string,
}).isRequired, }).isRequired,
getProject: PropTypes.func.isRequired,
clearPersistedState: PropTypes.func.isRequired,
params: PropTypes.shape({ project_id: PropTypes.string }).isRequired,
}; };
function mapStateToProps(state) { function mapStateToProps(state) {