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 #12422 from petemill/fix/issue-11859
Browse files Browse the repository at this point in the history
Reinstate call to cleanup window data
  • Loading branch information
bsclifton authored Dec 28, 2017
2 parents 358641a + 947c213 commit 119e4e7
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 18 deletions.
3 changes: 1 addition & 2 deletions app/browser/reducers/windowsReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,9 +329,8 @@ const windowsReducer = (state, action, immutableAction) => {
break
case appConstants.APP_WINDOW_CLOSED:
state = windowState.removeWindow(state, action)
const windowId = action.getIn(['windowValue', 'windowId'])
const windowId = action.get('windowId')
sessionStoreShutdown.removeWindowFromCache(windowId)
windows.cleanupWindow(windowId)
break
case appConstants.APP_WINDOW_CREATED:
case appConstants.APP_WINDOW_RESIZED:
Expand Down
2 changes: 2 additions & 0 deletions app/browser/windows.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@ const api = {
appActions.windowCreated(windowValue, windowId)
})
win.once('closed', () => {
appActions.windowClosed(windowId)
cleanupWindow(windowId)
})
win.on('blur', () => {
appActions.windowBlurred(windowId)
Expand Down
3 changes: 1 addition & 2 deletions app/common/state/windowState.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@ const api = {
removeWindow: (state, action) => {
action = validateAction(action)
state = validateState(state)
let windowValue = validateWindowValue(action.get('windowValue'))
let windowId = validateId('windowId', windowValue.get('windowId'))
const windowId = action.get('windowId')
return api.removeWindowByWindowId(state, windowId)
},

Expand Down
4 changes: 2 additions & 2 deletions js/actions/appActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ const appActions = {
})
},

windowClosed: function (windowValue) {
windowClosed: function (windowId) {
dispatch({
actionType: appConstants.APP_WINDOW_CLOSED,
windowValue
windowId
})
},

Expand Down
20 changes: 8 additions & 12 deletions test/unit/common/state/windowStateTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,12 @@ const shouldValidateWindowValue = function (check) {
})
}

const shouldValidateAction = function (check) {
const shouldValidateAction = function (check, payload = { windowValue: { windowId: 1 } }) {
it('throws an AssertionError if action does not contain a `windowValue` that is convertable to an Immutable.Map', function () {
assert.doesNotThrow(
() => {
check(Immutable.fromJS({ windowValue: { windowId: 1 } }))
check({ windowValue: { windowId: 1 } })
check(Immutable.fromJS(payload))
check(payload)
},
AssertionError
)
Expand All @@ -142,7 +142,7 @@ const shouldValidateAction = function (check) {
it('throws an AssertionError if `action` is not convertable to an Immutable.Map', function () {
assert.doesNotThrow(
() => {
check({ windowValue: { windowId: 1 } })
check(payload)
},
AssertionError
)
Expand Down Expand Up @@ -327,24 +327,20 @@ describe('windowState', function () {

it('returns a new immutable state with the window removed by `windowId`', function () {
assert.deepEqual(
windowState.removeWindow(this.appState, { windowValue: { windowId: 2 } }).get('windows').toJS(),
windowState.removeWindow(this.appState, { windowId: 2 }).get('windows').toJS(),
[{ windowId: 1 }])
})

shouldValidateAction((action) => {
windowState.removeWindow(defaultAppState, action)
})

shouldValidateWindowValue((windowValue) => {
windowState.removeWindow(defaultAppState, { windowValue })
})
}, { windowId: 1 })

shouldValidateId((windowId) => {
windowState.removeWindow(defaultAppState, { windowValue: { windowId } })
windowState.removeWindow(defaultAppState, { windowId })
})

shouldValidateWindowState((state) => {
windowState.removeWindow(state, { windowValue: { windowId: 1 } })
windowState.removeWindow(state, { windowId: 1 })
})
})

Expand Down

0 comments on commit 119e4e7

Please sign in to comment.