diff options
author | Phil Hughes <me@iamphill.com> | 2018-04-27 16:42:57 +0300 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2018-04-27 16:42:57 +0300 |
commit | eeb41af7285e5b4c6d8f6925f37a71e71bedb0e4 (patch) | |
tree | e19d101c0728e59c16c95b5a8a6faf46cd0dadfd /app/assets/javascripts/ide/stores/mutations | |
parent | eb83edafd4bf13d57608503025a8857ea9535053 (diff) |
specs
Diffstat (limited to 'app/assets/javascripts/ide/stores/mutations')
-rw-r--r-- | app/assets/javascripts/ide/stores/mutations/file.js | 45 |
1 files changed, 17 insertions, 28 deletions
diff --git a/app/assets/javascripts/ide/stores/mutations/file.js b/app/assets/javascripts/ide/stores/mutations/file.js index 7f670eb744c..43cb49b9918 100644 --- a/app/assets/javascripts/ide/stores/mutations/file.js +++ b/app/assets/javascripts/ide/stores/mutations/file.js @@ -170,35 +170,24 @@ export default { }, [types.ADD_PENDING_TAB](state, { file, keyPrefix = 'pending' }) { const key = `${keyPrefix}-${file.key}`; - const pendingTab = state.openFiles.find(f => f.key === key && f.pending); - let openFiles = state.openFiles.map(f => Object.assign(f, { active: false, opened: false })); - if (!pendingTab) { - const openFile = openFiles.find(f => f.path === file.path); - - openFiles = openFiles.concat(openFile ? null : file).reduce((acc, f) => { - if (!f) return acc; - - if (f.path === file.path) { - return acc.concat({ - ...f, - content: file.content, - active: true, - pending: true, - opened: true, - key, - }); - } - - return acc.concat(f); - }, []); - } else { - openFiles = state.openFiles.map(f => - Object.assign(f, { active: f.key === key, opened: f.key === key }), - ); - } - - Object.assign(state, { openFiles }); + Object.assign(state, { + entries: Object.assign(state.entries, { + [file.path]: Object.assign(state.entries[file.path], { + opened: false, + active: false, + }), + }), + openFiles: [ + { + ...file, + key, + pending: true, + opened: true, + active: true, + }, + ], + }); }, [types.REMOVE_PENDING_TAB](state, file) { Object.assign(state, { |