after loading project, switch to code tab
This commit is contained in:
1 parent
cabd92a6c3
commit
f03c251f00
2 files changed
+22
No files matched your search
@@ -8,12 +8,18 @@ import {setProjectUnchanged} from '../reducers/project-changed';
|
||||
import {
|
||||
LoadingStates,
|
||||
defaultProjectId,
|
||||
getIsCreatingNew,
|
||||
getIsFetchingWithId,
|
||||
getIsLoading,
|
||||
getIsShowingProject,
|
||||
onFetchedProjectData,
|
||||
projectError,
|
||||
setProjectId
|
||||
} from '../reducers/project-state';
|
||||
import {
|
||||
activateTab,
|
||||
BLOCKS_TAB_INDEX
|
||||
} from '../reducers/editor-tab';
|
||||
|
||||
import analytics from './analytics';
|
||||
import log from './log';
|
||||
@@ -59,6 +65,9 @@ const ProjectFetcherHOC = function (WrappedComponent) {
|
||||
if (this.props.isShowingProject && !prevProps.isShowingProject) {
|
||||
this.props.onProjectLoaded();
|
||||
}
|
||||
if (this.props.isShowingProject && (prevProps.isLoadingProject || prevProps.isCreatingNew)) {
|
||||
this.props.onActivateTab(BLOCKS_TAB_INDEX);
|
||||
}
|
||||
}
|
||||
fetchProject (projectId, loadingState) {
|
||||
return storage
|
||||
@@ -89,7 +98,9 @@ const ProjectFetcherHOC = function (WrappedComponent) {
|
||||
/* eslint-disable no-unused-vars */
|
||||
assetHost,
|
||||
intl,
|
||||
isLoadingProject: isLoadingProjectProp,
|
||||
loadingState,
|
||||
onActivateTab,
|
||||
onError: onErrorProp,
|
||||
onFetchedProjectData: onFetchedProjectDataProp,
|
||||
projectHost,
|
||||
@@ -113,7 +124,9 @@ const ProjectFetcherHOC = function (WrappedComponent) {
|
||||
canSave: PropTypes.bool,
|
||||
intl: intlShape.isRequired,
|
||||
isFetchingWithId: PropTypes.bool,
|
||||
isLoadingProject: PropTypes.bool,
|
||||
loadingState: PropTypes.oneOf(LoadingStates),
|
||||
onActivateTab: PropTypes.func,
|
||||
onError: PropTypes.func,
|
||||
onFetchedProjectData: PropTypes.func,
|
||||
projectHost: PropTypes.string,
|
||||
@@ -127,12 +140,15 @@ const ProjectFetcherHOC = function (WrappedComponent) {
|
||||
};
|
||||
|
||||
const mapStateToProps = state => ({
|
||||
isCreatingNew: getIsCreatingNew(state.scratchGui.projectState.loadingState),
|
||||
isFetchingWithId: getIsFetchingWithId(state.scratchGui.projectState.loadingState),
|
||||
isLoadingProject: getIsLoading(state.scratchGui.projectState.loadingState),
|
||||
isShowingProject: getIsShowingProject(state.scratchGui.projectState.loadingState),
|
||||
loadingState: state.scratchGui.projectState.loadingState,
|
||||
reduxProjectId: state.scratchGui.projectState.projectId
|
||||
});
|
||||
const mapDispatchToProps = dispatch => ({
|
||||
onActivateTab: tab => dispatch(activateTab(tab)),
|
||||
onError: error => dispatch(projectError(error)),
|
||||
onFetchedProjectData: (projectData, loadingState) =>
|
||||
dispatch(onFetchedProjectData(projectData, loadingState)),
|
||||
|
||||
@@ -58,6 +58,11 @@ const getIsLoadingWithId = loadingState => (
|
||||
loadingState === LoadingState.LOADING_VM_WITH_ID ||
|
||||
loadingState === LoadingState.LOADING_VM_NEW_DEFAULT
|
||||
);
|
||||
const getIsLoading = loadingState => (
|
||||
loadingState === LoadingState.LOADING_VM_FILE_UPLOAD ||
|
||||
loadingState === LoadingState.LOADING_VM_WITH_ID ||
|
||||
loadingState === LoadingState.LOADING_VM_NEW_DEFAULT
|
||||
);
|
||||
const getIsCreatingNew = loadingState => (
|
||||
loadingState === LoadingState.CREATING_NEW
|
||||
);
|
||||
@@ -488,6 +493,7 @@ export {
|
||||
getIsError,
|
||||
getIsFetchingWithId,
|
||||
getIsFetchingWithoutId,
|
||||
getIsLoading,
|
||||
getIsLoadingWithId,
|
||||
getIsManualUpdating,
|
||||
getIsRemixing,
|
||||
|
||||
Reference in new issue
Block a user