diff --git a/app/renderer/reducers/frameReducer.js b/app/renderer/reducers/frameReducer.js index 839073ec8cf..db33b0c6492 100644 --- a/app/renderer/reducers/frameReducer.js +++ b/app/renderer/reducers/frameReducer.js @@ -121,40 +121,40 @@ const frameReducer = (state, action, immutableAction) => { const pinned = immutableAction.getIn(['changeInfo', 'pinned']) if (pinned != null) { if (pinned) { - const history = state.getIn(['frames', index, 'history']) + const history = state.getIn(['frames', sourceFrameIndex, 'history']) if (history && history.size !== 0) { - state = state.setIn(['frames', index, 'pinnedLocation'], history.first()) + state = state.setIn(['frames', sourceFrameIndex, 'pinnedLocation'], history.first()) } else { - state = state.setIn(['frames', index, 'pinnedLocation'], tab.get('url')) + state = state.setIn(['frames', sourceFrameIndex, 'pinnedLocation'], tab.get('url')) } } else { - state = state.deleteIn(['frames', index, 'pinnedLocation']) + state = state.deleteIn(['frames', sourceFrameIndex, 'pinnedLocation']) } } // handle pinned tabs that are created as pinned const url = immutableAction.getIn(['changeInfo', 'url']) if (url != null && tab.get('pinned') === true) { - const pinnedLocation = state.getIn(['frames', index, 'pinnedLocation']) + const pinnedLocation = state.getIn(['frames', sourceFrameIndex, 'pinnedLocation']) if (!pinnedLocation || pinnedLocation === 'about:blank' || pinnedLocation === '') { - const history = state.getIn(['frames', index, 'history']) + const history = state.getIn(['frames', sourceFrameIndex, 'history']) if (history && history.size !== 0) { - state = state.setIn(['frames', index, 'pinnedLocation'], history.first()) + state = state.setIn(['frames', sourceFrameIndex, 'pinnedLocation'], history.first()) } else { - state = state.setIn(['frames', index, 'pinnedLocation'], tab.get('url')) + state = state.setIn(['frames', sourceFrameIndex, 'pinnedLocation'], tab.get('url')) } } } const title = tab.get('title') if (title != null) { - state = state.setIn(['frames', index, 'title'], title) + state = state.setIn(['frames', sourceFrameIndex, 'title'], title) } const active = tab.get('active') if (active != null) { if (active) { state = frameStateUtil.setActiveFrameKey(state, frame.get('key')) - state = frameStateUtil.setFrameLastAccessedTime(state, index) + state = frameStateUtil.setFrameLastAccessedTime(state, sourceFrameIndex) // Handle tabPage updates and preview cancelation based on tab updated // otherwise tabValue will fire those events each time a tab finish loading diff --git a/test/unit/app/renderer/reducers/frameReducerTest.js b/test/unit/app/renderer/reducers/frameReducerTest.js index c876e969d80..56f7e945a7e 100644 --- a/test/unit/app/renderer/reducers/frameReducerTest.js +++ b/test/unit/app/renderer/reducers/frameReducerTest.js @@ -291,6 +291,18 @@ describe('frameReducer', function () { // Old index 2 moves 1 to the left assert.equal(this.newState.toJS().frames[1].tabId, windowState.toJS().frames[2].tabId) }) + it('new frame has not showed up in frames', function () { + const action = { + actionType: appConstants.APP_TAB_UPDATED, + tabValue: { + tabId: 13, + index: 3, + title: 'Bondy Power!' + } + } + this.newState = frameReducer(windowState, action, Immutable.fromJS(action)) + assert.equal(this.newState.toJS().frames.length, windowState.toJS().frames.length) + }) }) describe('when pinned status changes', function () { // TODO(bbondy): Noticed this is missing while in the context of fixing an unrelated thing.