Add back event on file save sucess

This commit is contained in:
Anthony Laibe 2018-10-31 16:55:25 +01:00
parent a9bf409aa0
commit 436786bfe4
3 changed files with 9 additions and 3 deletions

View File

@ -289,7 +289,7 @@ export const file = {
export const SAVE_FILE = createRequestTypes('SAVE_FILE');
export const saveFile = {
request: ({name, path, content}) => action(SAVE_FILE[REQUEST], {name, path, content}),
success: (_, {name, path, content}) => action(SAVE_FILE[SUCCESS], {name, path, content}),
success: (file) => action(SAVE_FILE[SUCCESS], {file}),
failure: (error) => action(SAVE_FILE[FAILURE], {error})
};

View File

@ -208,6 +208,10 @@ export function *watchPostFile() {
yield takeEvery(actions.SAVE_FILE[actions.REQUEST], postFile);
}
export function *watchPostFileSuccess() {
yield takeEvery(actions.SAVE_FILE[actions.SUCCESS], addEditorTabs);
}
export function *watchDeleteFile() {
yield takeEvery(actions.REMOVE_FILE[actions.REQUEST], deleteFile);
}
@ -539,5 +543,6 @@ export default function *root() {
fork(watchRemoveEditorTabs),
fork(watchAddEditorTabsSuccess),
fork(watchRemoveEditorTabsSuccess),
fork(watchPostFileSuccess)
]);
}

View File

@ -4,9 +4,10 @@ export function addEditorTabs({file}) {
editorTabs.forEach(f => f.active = false);
const alreadyAddedFile = editorTabs.find(f => f.name === file.name)
if (alreadyAddedFile) {
alreadyAddedFile.active = true
alreadyAddedFile.active = true;
alreadyAddedFile.content = file.content;
} else {
file.active = true
file.active = true;
editorTabs.push(file);
}
localStorage.setItem('editorTabs', JSON.stringify(editorTabs));