From 95b11a7b7de409ad7f0340fdb5eec6e119ecf121 Mon Sep 17 00:00:00 2001 From: Ben Wheeler Date: Thu, 10 Jan 2019 17:27:26 -0500 Subject: [PATCH] resolve function name conflict by renaming onProjectLoaded in project-fetcher-hoc https://github.com/LLK/scratch-gui/pull/4312 had a function name conflict with the existing code. This change fixes that by renaming the conflicting function, and removes redundant code. --- src/containers/gui.jsx | 6 +----- src/lib/project-fetcher-hoc.jsx | 7 ++++--- src/reducers/project-state.js | 5 ----- 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/src/containers/gui.jsx b/src/containers/gui.jsx index fd93fd01b..14e3c35ab 100644 --- a/src/containers/gui.jsx +++ b/src/containers/gui.jsx @@ -9,7 +9,6 @@ import {defineMessages, injectIntl, intlShape} from 'react-intl'; import ErrorBoundaryHOC from '../lib/error-boundary-hoc.jsx'; import { getIsError, - getIsLoaded, getIsShowingProject } from '../reducers/project-state'; import {setProjectTitle} from '../reducers/project-title'; @@ -61,7 +60,7 @@ class GUI extends React.Component { if (this.props.projectTitle !== prevProps.projectTitle) { this.setReduxTitle(this.props.projectTitle); } - if (this.props.isProjectLoaded && !prevProps.isProjectLoaded) { + if (this.props.isShowingProject && !prevProps.isShowingProject) { // this only notifies container when a project changes from not yet loaded to loaded // At this time the project view in www doesn't need to know when a project is unloaded this.props.onProjectLoaded(); @@ -87,7 +86,6 @@ class GUI extends React.Component { cloudHost, error, isError, - isProjectLoaded, isScratchDesktop, isShowingProject, onProjectLoaded, @@ -125,7 +123,6 @@ GUI.propTypes = { intl: intlShape, isError: PropTypes.bool, isLoading: PropTypes.bool, - isProjectLoaded: PropTypes.bool, isScratchDesktop: PropTypes.bool, isShowingProject: PropTypes.bool, loadingStateVisible: PropTypes.bool, @@ -165,7 +162,6 @@ const mapStateToProps = state => { importInfoVisible: state.scratchGui.modals.importInfo, isError: getIsError(loadingState), isPlayerOnly: state.scratchGui.mode.isPlayerOnly, - isProjectLoaded: getIsLoaded(loadingState), isRtl: state.locales.isRtl, isShowingProject: getIsShowingProject(loadingState), loadingStateVisible: state.scratchGui.modals.loadingProject, diff --git a/src/lib/project-fetcher-hoc.jsx b/src/lib/project-fetcher-hoc.jsx index fadab3713..888e378f5 100644 --- a/src/lib/project-fetcher-hoc.jsx +++ b/src/lib/project-fetcher-hoc.jsx @@ -61,7 +61,7 @@ const ProjectFetcherHOC = function (WrappedComponent) { this.fetchProject(this.props.reduxProjectId, this.props.loadingState); } if (this.props.isShowingProject && !prevProps.isShowingProject) { - this.props.onProjectLoaded(); + this.props.onProjectUnchanged(); } if (this.props.isShowingProject && (prevProps.isLoadingProject || prevProps.isCreatingNew)) { this.props.onActivateTab(BLOCKS_TAB_INDEX); @@ -94,7 +94,7 @@ const ProjectFetcherHOC = function (WrappedComponent) { onActivateTab, onError: onErrorProp, onFetchedProjectData: onFetchedProjectDataProp, - onProjectLoaded, + onProjectUnchanged, projectHost, projectId, reduxProjectId, @@ -121,6 +121,7 @@ const ProjectFetcherHOC = function (WrappedComponent) { onActivateTab: PropTypes.func, onError: PropTypes.func, onFetchedProjectData: PropTypes.func, + onProjectUnchanged: PropTypes.func, projectHost: PropTypes.string, projectId: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), reduxProjectId: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), @@ -145,7 +146,7 @@ const ProjectFetcherHOC = function (WrappedComponent) { onFetchedProjectData: (projectData, loadingState) => dispatch(onFetchedProjectData(projectData, loadingState)), setProjectId: projectId => dispatch(setProjectId(projectId)), - onProjectLoaded: () => dispatch(setProjectUnchanged()) + onProjectUnchanged: () => dispatch(setProjectUnchanged()) }); // Allow incoming props to override redux-provided props. Used to mock in tests. const mergeProps = (stateProps, dispatchProps, ownProps) => Object.assign( diff --git a/src/reducers/project-state.js b/src/reducers/project-state.js index c4a73c149..7ea21bd3a 100644 --- a/src/reducers/project-state.js +++ b/src/reducers/project-state.js @@ -70,10 +70,6 @@ const getIsLoading = loadingState => ( const getIsLoadingUpload = loadingState => ( loadingState === LoadingState.LOADING_VM_FILE_UPLOAD ); -const getIsLoaded = loadingState => ( - loadingState === LoadingState.SHOWING_WITH_ID || - loadingState === LoadingState.SHOWING_WITHOUT_ID -); const getIsCreatingNew = loadingState => ( loadingState === LoadingState.CREATING_NEW ); @@ -551,7 +547,6 @@ export { getIsError, getIsFetchingWithId, getIsFetchingWithoutId, - getIsLoaded, getIsLoading, getIsLoadingWithId, getIsLoadingUpload,