From c4b44ccd054ad10fe21b8d7544f2f041fdbbf256 Mon Sep 17 00:00:00 2001 From: Karishma Chadha <kchadha@scratch.mit.edu> Date: Thu, 22 Mar 2018 16:09:47 -0400 Subject: [PATCH] Make load button work with new changes. --- src/containers/gui.jsx | 5 +---- src/containers/load-button.jsx | 6 ------ src/lib/project-loader-hoc.jsx | 2 +- src/reducers/modals.js | 11 ----------- 4 files changed, 2 insertions(+), 22 deletions(-) diff --git a/src/containers/gui.jsx b/src/containers/gui.jsx index 62ded94da..a5729f901 100644 --- a/src/containers/gui.jsx +++ b/src/containers/gui.jsx @@ -65,14 +65,13 @@ class GUI extends React.Component { const { children, fetchingProject, - loadingStateVisible, projectData, // eslint-disable-line no-unused-vars vm, ...componentProps } = this.props; return ( <GUIComponent - loading={fetchingProject || this.state.loading || loadingStateVisible} + loading={fetchingProject || this.state.loading} vm={vm} {...componentProps} > @@ -87,7 +86,6 @@ GUI.propTypes = { feedbackFormVisible: PropTypes.bool, fetchingProject: PropTypes.bool, importInfoVisible: PropTypes.bool, - loadingStateVisible: PropTypes.bool, previewInfoVisible: PropTypes.bool, // eslint-disable-line react/forbid-prop-types projectData: PropTypes.oneOfType([PropTypes.object, PropTypes.string]), @@ -102,7 +100,6 @@ const mapStateToProps = state => ({ costumesTabVisible: state.editorTab.activeTabIndex === COSTUMES_TAB_INDEX, feedbackFormVisible: state.modals.feedbackForm, importInfoVisible: state.modals.importInfo, - loadingStateVisible: state.modals.loadingProject, previewInfoVisible: state.modals.previewInfo, projectData: state.vm.projectData, soundsTabVisible: state.editorTab.activeTabIndex === SOUNDS_TAB_INDEX diff --git a/src/containers/load-button.jsx b/src/containers/load-button.jsx index 3587bfbdb..a5e90a255 100644 --- a/src/containers/load-button.jsx +++ b/src/containers/load-button.jsx @@ -4,8 +4,6 @@ import React from 'react'; import {connect} from 'react-redux'; import LoadButtonComponent from '../components/load-button/load-button.jsx'; - -import {openLoadingProject} from '../reducers/modals'; import {setProjectData} from '../reducers/vm'; class LoadButton extends React.Component { @@ -22,7 +20,6 @@ class LoadButton extends React.Component { }; } handleChange (e) { - this.props.openLoadingState(); const reader = new FileReader(); reader.onload = () => this.props.setNewProjectData(reader.result, null); reader.readAsArrayBuffer(e.target.files[0]); @@ -36,7 +33,6 @@ class LoadButton extends React.Component { render () { if (this.state.loadingError) throw new Error(`Failed to load project: ${this.state.errorMessage}`); const { - openLoadingState, // eslint-disable-line no-unused-vars setNewProjectData, // eslint-disable-line no-unused-vars ...props } = this.props; @@ -52,14 +48,12 @@ class LoadButton extends React.Component { } LoadButton.propTypes = { - openLoadingState: PropTypes.func, setNewProjectData: PropTypes.func }; const mapStateToProps = () => ({}); const mapDispatchToProps = dispatch => ({ - openLoadingState: () => dispatch(openLoadingProject()), setNewProjectData: (projectData, projectId) => dispatch(setProjectData(projectData, projectId)) }); diff --git a/src/lib/project-loader-hoc.jsx b/src/lib/project-loader-hoc.jsx index 1f096f660..fdf79edcf 100644 --- a/src/lib/project-loader-hoc.jsx +++ b/src/lib/project-loader-hoc.jsx @@ -33,7 +33,7 @@ const ProjectLoaderHOC = function (WrappedComponent) { // Replace URL hash without triggering a hash change event history.replaceState({}, document.title, projectId ? `./#${projectId}` : '.'); - + if (projectId === null) return; // load button triggered this and is already calling setProjectData this.setState({fetchingProject: true}, () => { storage .load(storage.AssetType.Project, projectId, storage.DataFormat.JSON) diff --git a/src/reducers/modals.js b/src/reducers/modals.js index 2a3772e59..ba038ff34 100644 --- a/src/reducers/modals.js +++ b/src/reducers/modals.js @@ -8,7 +8,6 @@ const MODAL_COSTUME_LIBRARY = 'costumeLibrary'; const MODAL_EXTENSION_LIBRARY = 'extensionLibrary'; const MODAL_FEEDBACK_FORM = 'feedbackForm'; const MODAL_IMPORT_INFO = 'importInfo'; -const MODAL_LOADING_PROJECT = 'loadingProject'; const MODAL_PREVIEW_INFO = 'previewInfo'; const MODAL_SOUND_LIBRARY = 'soundLibrary'; const MODAL_SPRITE_LIBRARY = 'spriteLibrary'; @@ -21,7 +20,6 @@ const initialState = { [MODAL_EXTENSION_LIBRARY]: false, [MODAL_FEEDBACK_FORM]: false, [MODAL_IMPORT_INFO]: false, - [MODAL_LOADING_PROJECT]: false, [MODAL_PREVIEW_INFO]: true, [MODAL_SOUND_LIBRARY]: false, [MODAL_SPRITE_LIBRARY]: false, @@ -75,10 +73,6 @@ const openImportInfo = function () { analytics.pageview('modals/import'); return openModal(MODAL_IMPORT_INFO); }; -const openLoadingProject = function () { - analytics.pageview('modals/loading'); - return openModal(MODAL_LOADING_PROJECT); -}; const openPreviewInfo = function () { analytics.pageview('/modals/preview'); return openModal(MODAL_PREVIEW_INFO); @@ -110,9 +104,6 @@ const closeFeedbackForm = function () { const closeImportInfo = function () { return closeModal(MODAL_IMPORT_INFO); }; -const closeLoadingProject = function () { - return closeModal(MODAL_LOADING_PROJECT); -}; const closePreviewInfo = function () { return closeModal(MODAL_PREVIEW_INFO); }; @@ -132,7 +123,6 @@ export { openExtensionLibrary, openFeedbackForm, openImportInfo, - openLoadingProject, openPreviewInfo, openSoundLibrary, openSpriteLibrary, @@ -142,7 +132,6 @@ export { closeExtensionLibrary, closeFeedbackForm, closeImportInfo, - closeLoadingProject, closePreviewInfo, closeSpriteLibrary, closeSoundLibrary, -- GitLab