diff --git a/app/common/state/tabState.js b/app/common/state/tabState.js index 07cf660b7e1..de01c258c1d 100644 --- a/app/common/state/tabState.js +++ b/app/common/state/tabState.js @@ -280,7 +280,7 @@ const tabState = { if (index === tabState.TAB_ID_NONE) { return null } - return makeImmutable(['tabs', index]) + return ['tabs', index] }, getByTabId: (state, tabId) => { @@ -534,7 +534,7 @@ const tabState = { if (path == null) { return null } - return path.push('frame') + return path.concat(['frame']) } else { return frameState.getPathByTabId(state, tabId) } @@ -603,13 +603,13 @@ const tabState = { if (!tabValue) { return state } - const path = tabState.getPathByTabId(state, tabId).push('navigationState') - return state.setIn(path, navigationState) + const path = tabState.getPathByTabId(state, tabId) + return path ? state.setIn(path.concat(['navigationState']), navigationState) : state }, getNavigationState: (state, tabId) => { const path = tabState.getPathByTabId(state, tabId) - return path ? state.getIn(path.push('navigationState'), Immutable.Map()) : null + return path ? state.getIn(path.concat(['navigationState']), Immutable.Map()) : null }, getVisibleEntry: (state, tabId) => { diff --git a/test/unit/app/common/state/tabStateTest.js b/test/unit/app/common/state/tabStateTest.js index 56fdc6ed70e..a530f179351 100644 --- a/test/unit/app/common/state/tabStateTest.js +++ b/test/unit/app/common/state/tabStateTest.js @@ -195,6 +195,15 @@ const shouldValidateAction = function (cb) { } describe('tabState unit tests', function () { + describe('getPathByTabId', function () { + it('returns null if tab is not found', function () { + assert.equal(tabState.getPathByTabId(twoTabsAppState, 333), null) + }) + it('returns path if index found (as mutable array)', function () { + assert.deepEqual(tabState.getPathByTabId(twoTabsAppState, 1), ['tabs', 0]) + }) + }) + describe('getByTabId', function () { before(function () { this.appState = twoTabsAppState