diff options
author | Phil Hughes <me@iamphill.com> | 2018-03-28 15:05:26 +0300 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2018-03-28 16:08:38 +0300 |
commit | 029f7e6cd87ec0d59b85f12b57ee3c3a889dac1f (patch) | |
tree | f41cea322d4731466e1d768aa4c96c3c97663f2d /app/assets/javascripts/ide/ide_router.js | |
parent | af20c4423c85c263f34a09c276a7bb917e3554a5 (diff) |
removed file changes that have no changes to make diff easier
simplified SET_FILE_ACTIVE openFiles map
use .find in router so that it returns early instead of looping all the
values
Diffstat (limited to 'app/assets/javascripts/ide/ide_router.js')
-rw-r--r-- | app/assets/javascripts/ide/ide_router.js | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/app/assets/javascripts/ide/ide_router.js b/app/assets/javascripts/ide/ide_router.js index 25f55ac2f8a..a6013784677 100644 --- a/app/assets/javascripts/ide/ide_router.js +++ b/app/assets/javascripts/ide/ide_router.js @@ -77,16 +77,12 @@ router.beforeEach((to, from, next) => { if (to.params[0]) { const path = to.params[0].slice(-1) === '/' ? to.params[0].slice(0, -1) : to.params[0]; - const treeEntry = Object.keys(store.state.entries).reduce((acc, key) => { - const file = store.state.entries[key]; - if (key === path && !file.pending) { - return file; - } + const treeEntryKey = Object.keys(store.state.entries).find( + key => key === path && !store.state.entries[key].pending, + ); + const treeEntry = store.state.entries[treeEntryKey]; - return acc; - }, {}); - - if (Object.keys(treeEntry).length) { + if (treeEntry) { store.dispatch('handleTreeEntryAction', treeEntry); } } |