Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
Merge pull request #11192 from brave/issue-11070
Browse files Browse the repository at this point in the history
Using souceFrameIndex because new frame hasn't showed up in frames
  • Loading branch information
bbondy committed Sep 28, 2017
1 parent 7941690 commit f5baeba
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
20 changes: 10 additions & 10 deletions app/renderer/reducers/frameReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,40 +119,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
Expand Down
12 changes: 12 additions & 0 deletions test/unit/app/renderer/reducers/frameReducerTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit f5baeba

Please sign in to comment.