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

Commit aead103

Browse files
bridiverbsclifton
authored andcommitted
update activeFrameKey when the active tab changes
auditors @bbondy @bsclifton
1 parent 81fd962 commit aead103

File tree

3 files changed

+10
-21
lines changed

3 files changed

+10
-21
lines changed

js/components/frame.js

-7
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,6 @@ class Frame extends React.Component {
206206
}
207207

208208
onPropsChanged (prevProps = {}) {
209-
if (this.props.isTabActive && !prevProps.isTabActive) {
210-
windowActions.activeFrameChanged(this.frame)
211-
}
212209
if (this.props.tabIndex !== prevProps.tabIndex) {
213210
this.webview.setTabIndex(this.props.tabIndex)
214211
}
@@ -218,9 +215,6 @@ class Frame extends React.Component {
218215
}
219216

220217
componentDidMount () {
221-
if (this.props.isTabActive) {
222-
windowActions.activeFrameChanged(this.frame)
223-
}
224218
this.updateWebview(this.onPropsChanged)
225219
if (this.props.activeShortcut) {
226220
this.handleShortcut()
@@ -954,7 +948,6 @@ class Frame extends React.Component {
954948
props.isFullScreen = frame.get('isFullScreen')
955949
props.isPreview = frame.get('key') === currentWindow.get('previewFrameKey')
956950
props.isActive = frameStateUtil.isFrameKeyActive(currentWindow, frame.get('key'))
957-
props.isTabActive = tab ? tabState.isActive(state, tabId) : false
958951
props.showFullScreenWarning = frame.get('showFullScreenWarning')
959952
props.location = frame.get('location')
960953
props.hrefPreview = frame.get('hrefPreview')

js/constants/windowConstants.js

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ const mapValuesByKeys = require('../lib/functional').mapValuesByKeys
66

77
const _ = null
88
const windowConstants = {
9-
WINDOW_ACTIVE_FRAME_CHANGED: _,
109
WINDOW_SET_NAVBAR_INPUT: _,
1110
WINDOW_CLOSE_FRAME: _,
1211
WINDOW_CLOSE_FRAMES: _,

js/stores/windowStore.js

+10-13
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,16 @@ const tabDataChanged = (state, action) => {
242242
if (frameProps) {
243243
state = state.mergeIn(['frames', frameStateUtil.getFramePropsIndex(frameStateUtil.getFrames(state), frameProps)], newProps)
244244
state = state.mergeIn(['tabs', frameStateUtil.getFramePropsIndex(frameStateUtil.getFrames(state), frameProps)], newProps)
245+
if (tab.get('active') === true && tab.get('windowId') === getCurrentWindowId()) {
246+
state = state.merge({
247+
activeFrameKey: frameProps.get('key'),
248+
previewFrameKey: null
249+
})
250+
state = state.mergeIn(['frames', frameStateUtil.getFramePropsIndex(frameStateUtil.getFrames(state), action.frameProps)], {
251+
lastAccessedTime: new Date().getTime() })
252+
state = state.deleteIn(['ui', 'tabs', 'previewTabPageIndex'])
253+
state = updateTabPageIndex(state, frameProps)
254+
}
245255
}
246256
})
247257
return state
@@ -381,19 +391,6 @@ const doAction = (action) => {
381391
case windowConstants.WINDOW_CLEAR_CLOSED_FRAMES:
382392
windowState = windowState.set('closedFrames', new Immutable.List())
383393
break
384-
case windowConstants.WINDOW_ACTIVE_FRAME_CHANGED:
385-
if (!action.frameProps) {
386-
break
387-
}
388-
windowState = windowState.merge({
389-
activeFrameKey: action.frameProps.get('key'),
390-
previewFrameKey: null
391-
})
392-
windowState = windowState.mergeIn(['frames', frameStateUtil.getFramePropsIndex(frameStateUtil.getFrames(windowState), action.frameProps)], {
393-
lastAccessedTime: new Date().getTime() })
394-
windowState = windowState.deleteIn(['ui', 'tabs', 'previewTabPageIndex'])
395-
windowState = updateTabPageIndex(windowState, action.frameProps)
396-
break
397394
case windowConstants.WINDOW_SET_PREVIEW_FRAME:
398395
windowState = windowState.merge({
399396
previewFrameKey: action.frameProps && action.frameProps.get('key') !== windowState.get('activeFrameKey')

0 commit comments

Comments
 (0)