Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix : Folders auto-expand on save #2543

27 changes: 23 additions & 4 deletions client/modules/IDE/reducers/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,28 @@ const files = (state, action) => {
}
return Object.assign({}, file, { blobURL: action.blobURL });
});
case ActionTypes.NEW_PROJECT:
return setFilePaths(action.files);
case ActionTypes.SET_PROJECT:
return setFilePaths(action.files);
case ActionTypes.NEW_PROJECT: {
const newFiles = action.files.map((file) => {
const corrospondingObj = state.find((obj) => obj.id === file.id);
if (corrospondingObj && corrospondingObj.fileType === 'folder') {
const isFolderClosed = corrospondingObj.isFolderClosed || false;
return { ...file, isFolderClosed };
}
return file;
});
return setFilePaths(newFiles);
}
case ActionTypes.SET_PROJECT: {
const newFiles = action.files.map((file) => {
const corrospondingObj = state.find((obj) => obj.id === file.id);
if (corrospondingObj && corrospondingObj.fileType === 'folder') {
const isFolderClosed = corrospondingObj.isFolderClosed || false;
return { ...file, isFolderClosed };
}
return file;
});
return setFilePaths(newFiles);
}
case ActionTypes.RESET_PROJECT:
return initialState();
case ActionTypes.CREATE_FILE: {
Expand All @@ -188,6 +206,7 @@ const files = (state, action) => {
filePath
}
];

return newState.map((file) => {
if (file.id === action.parentId) {
file.children = sortedChildrenId(newState, file.children);
Expand Down
Loading