Skip to content
Snippets Groups Projects
Commit 8f28ed26 authored by Ben Wheeler's avatar Ben Wheeler
Browse files

partial solution to reloading-on-switch-to-editor problem

parent e70d0472
Branches
Tags
No related merge requests found
......@@ -38,6 +38,7 @@ const reducer = function (state, action) {
case TRANSITION_STATE:
// "from" state must be either an array that includes current project state,
// or null/undefined
debugger;
if (state.projectState in action.transitions || ProjectState.ANY in action.transitions) {
// const resultState = action.transitions[state.projectState];
switch (action.transitions[state.projectState] ?
......@@ -47,6 +48,18 @@ const reducer = function (state, action) {
projectId: action.id,
projectState: ProjectState.FETCHING_WITH_ID
});
case ProjectState.FETCH_WITH_ID_IF_DIFFERENT:
if (state.projectId === action.id) { // don't re-fetch and reload same data
return Object.assign({}, state, {
projectId: action.id,
projectState: ProjectState.SHOWING_WITH_ID
});
}
// else, it's a new project id, so do fetch it
return Object.assign({}, state, {
projectId: action.id,
projectState: ProjectState.FETCHING_WITH_ID
});
case ProjectState.FETCHING_FILE_UPLOAD:
// goes straight to LOADING_VM_FILE_UPLOAD
return Object.assign({}, state, {
......@@ -102,7 +115,10 @@ const setProjectId = function (id) {
const setInitialProjectId = id => ({
type: TRANSITION_STATE,
transitions: {
[ProjectState.NOT_LOADED]: ProjectState.FETCHING_WITH_ID
[ProjectState.NOT_LOADED]: ProjectState.FETCHING_WITH_ID,
// if alreadin in the middle of fetching, just start fetching over
[ProjectState.FETCHING_WITH_ID]: ProjectState.FETCHING_WITH_ID,
[ProjectState.SHOWING_WITH_ID]: ProjectState.FETCH_WITH_ID_IF_DIFFERENT
},
id: id
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment