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

Commit

Permalink
Fixes close tabs to the left/right
Browse files Browse the repository at this point in the history
when you have multiple tab pages

Resolves #9789

Auditors: @bsclifton

Test Plan:
  • Loading branch information
NejcZdovc committed Jul 14, 2017
1 parent 2cdb625 commit 96d3a14
Show file tree
Hide file tree
Showing 4 changed files with 17,927 additions and 12 deletions.
34 changes: 23 additions & 11 deletions app/renderer/reducers/frameReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,21 +186,33 @@ const frameReducer = (state, action, immutableAction) => {
})
break
case windowConstants.WINDOW_CLOSE_OTHER_FRAMES:
const currentIndex = frameStateUtil.getIndexByTabId(state, action.tabId)
if (currentIndex === -1) {
return
}
{
const currentIndex = frameStateUtil.getIndexByTabId(state, action.tabId)
if (currentIndex === -1) {
break
}

state.get('frames').forEach((frame, i) => {
if (!frame.get('pinnedLocation') &&
((i < currentIndex && action.isCloseLeft) || (i > currentIndex && action.isCloseRight))) {
if (frame) {
appActions.tabCloseRequested(frame.get('tabId'))
let tabs = []

state.get('frames').forEach((frame, i) => {
if (!frame.get('pinnedLocation') &&
((i < currentIndex && action.isCloseLeft) || (i > currentIndex && action.isCloseRight))) {
if (frame) {
tabs.push(frame.get('tabId'))
appActions.tabCloseRequested(frame.get('tabId'))
}
}
}
})
})

// TODO(nejc) this can be simplified when states are merged
const newFrames = state.get('frames').filter(frame => !tabs.includes(frame.get('tabId')))
let newState = state.set('frames', newFrames)
newState = frameStateUtil.updateTabPageIndex(newState, action.tabId)
const index = newState.getIn(['ui', 'tabs', 'tabPageIndex'], 0)
state = state.setIn(['ui', 'tabs', 'tabPageIndex'], index)
}
break

case windowConstants.WINDOW_CLOSE_FRAME:
state = closeFrame(state, action)
break
Expand Down
Loading

0 comments on commit 96d3a14

Please sign in to comment.