diff --git a/embark-ui/src/actions/index.js b/embark-ui/src/actions/index.js index 9c59fb961..1e11caaba 100644 --- a/embark-ui/src/actions/index.js +++ b/embark-ui/src/actions/index.js @@ -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}) }; diff --git a/embark-ui/src/sagas/index.js b/embark-ui/src/sagas/index.js index 99b64238a..bd705cd46 100644 --- a/embark-ui/src/sagas/index.js +++ b/embark-ui/src/sagas/index.js @@ -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) ]); } diff --git a/embark-ui/src/services/storage.js b/embark-ui/src/services/storage.js index ec462edfd..e83a85a55 100644 --- a/embark-ui/src/services/storage.js +++ b/embark-ui/src/services/storage.js @@ -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));