mirror of https://github.com/embarklabs/embark.git
Merge pull request #1017 from embark-framework/chores/add-back-on-save-success
Add back event on file save sucess
This commit is contained in:
commit
13f0b766a7
|
@ -289,7 +289,7 @@ export const file = {
|
||||||
export const SAVE_FILE = createRequestTypes('SAVE_FILE');
|
export const SAVE_FILE = createRequestTypes('SAVE_FILE');
|
||||||
export const saveFile = {
|
export const saveFile = {
|
||||||
request: ({name, path, content}) => action(SAVE_FILE[REQUEST], {name, path, content}),
|
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})
|
failure: (error) => action(SAVE_FILE[FAILURE], {error})
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -208,6 +208,10 @@ export function *watchPostFile() {
|
||||||
yield takeEvery(actions.SAVE_FILE[actions.REQUEST], postFile);
|
yield takeEvery(actions.SAVE_FILE[actions.REQUEST], postFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function *watchPostFileSuccess() {
|
||||||
|
yield takeEvery(actions.SAVE_FILE[actions.SUCCESS], addEditorTabs);
|
||||||
|
}
|
||||||
|
|
||||||
export function *watchDeleteFile() {
|
export function *watchDeleteFile() {
|
||||||
yield takeEvery(actions.REMOVE_FILE[actions.REQUEST], deleteFile);
|
yield takeEvery(actions.REMOVE_FILE[actions.REQUEST], deleteFile);
|
||||||
}
|
}
|
||||||
|
@ -539,5 +543,6 @@ export default function *root() {
|
||||||
fork(watchRemoveEditorTabs),
|
fork(watchRemoveEditorTabs),
|
||||||
fork(watchAddEditorTabsSuccess),
|
fork(watchAddEditorTabsSuccess),
|
||||||
fork(watchRemoveEditorTabsSuccess),
|
fork(watchRemoveEditorTabsSuccess),
|
||||||
|
fork(watchPostFileSuccess)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,10 @@ export function addEditorTabs({file}) {
|
||||||
editorTabs.forEach(f => f.active = false);
|
editorTabs.forEach(f => f.active = false);
|
||||||
const alreadyAddedFile = editorTabs.find(f => f.name === file.name)
|
const alreadyAddedFile = editorTabs.find(f => f.name === file.name)
|
||||||
if (alreadyAddedFile) {
|
if (alreadyAddedFile) {
|
||||||
alreadyAddedFile.active = true
|
alreadyAddedFile.active = true;
|
||||||
|
alreadyAddedFile.content = file.content;
|
||||||
} else {
|
} else {
|
||||||
file.active = true
|
file.active = true;
|
||||||
editorTabs.push(file);
|
editorTabs.push(file);
|
||||||
}
|
}
|
||||||
localStorage.setItem('editorTabs', JSON.stringify(editorTabs));
|
localStorage.setItem('editorTabs', JSON.stringify(editorTabs));
|
||||||
|
|
Loading…
Reference in New Issue