From 4211ee58a517c1a5e7e026f17dd5d9418b7c3b3e Mon Sep 17 00:00:00 2001 From: bridiver Date: Thu, 11 May 2017 12:33:38 -0700 Subject: [PATCH] update activeFrameKey when the active tab changes auditors @bbondy @bsclifton --- js/components/frame.js | 7 ------- js/constants/windowConstants.js | 1 - js/stores/windowStore.js | 23 ++++++++++------------- 3 files changed, 10 insertions(+), 21 deletions(-) diff --git a/js/components/frame.js b/js/components/frame.js index 55f7fad9b1b..0835e4e7e4b 100644 --- a/js/components/frame.js +++ b/js/components/frame.js @@ -206,9 +206,6 @@ class Frame extends React.Component { } onPropsChanged (prevProps = {}) { - if (this.props.isTabActive && !prevProps.isTabActive) { - windowActions.activeFrameChanged(this.frame) - } if (this.props.tabIndex !== prevProps.tabIndex) { this.webview.setTabIndex(this.props.tabIndex) } @@ -218,9 +215,6 @@ class Frame extends React.Component { } componentDidMount () { - if (this.props.isTabActive) { - windowActions.activeFrameChanged(this.frame) - } this.updateWebview(this.onPropsChanged) if (this.props.activeShortcut) { this.handleShortcut() @@ -954,7 +948,6 @@ class Frame extends React.Component { props.isFullScreen = frame.get('isFullScreen') props.isPreview = frame.get('key') === currentWindow.get('previewFrameKey') props.isActive = frameStateUtil.isFrameKeyActive(currentWindow, frame.get('key')) - props.isTabActive = tab ? tabState.isActive(state, tabId) : false props.showFullScreenWarning = frame.get('showFullScreenWarning') props.location = frame.get('location') props.hrefPreview = frame.get('hrefPreview') diff --git a/js/constants/windowConstants.js b/js/constants/windowConstants.js index 7ffe9537f63..c7af80c32b7 100644 --- a/js/constants/windowConstants.js +++ b/js/constants/windowConstants.js @@ -6,7 +6,6 @@ const mapValuesByKeys = require('../lib/functional').mapValuesByKeys const _ = null const windowConstants = { - WINDOW_ACTIVE_FRAME_CHANGED: _, WINDOW_SET_NAVBAR_INPUT: _, WINDOW_CLOSE_FRAME: _, WINDOW_CLOSE_FRAMES: _, diff --git a/js/stores/windowStore.js b/js/stores/windowStore.js index 86fbb0ed24d..a981a90beed 100644 --- a/js/stores/windowStore.js +++ b/js/stores/windowStore.js @@ -242,6 +242,16 @@ const tabDataChanged = (state, action) => { if (frameProps) { state = state.mergeIn(['frames', frameStateUtil.getFramePropsIndex(frameStateUtil.getFrames(state), frameProps)], newProps) state = state.mergeIn(['tabs', frameStateUtil.getFramePropsIndex(frameStateUtil.getFrames(state), frameProps)], newProps) + if (tab.get('active') === true && tab.get('windowId') === getCurrentWindowId()) { + state = state.merge({ + activeFrameKey: frameProps.get('key'), + previewFrameKey: null + }) + state = state.mergeIn(['frames', frameStateUtil.getFramePropsIndex(frameStateUtil.getFrames(state), action.frameProps)], { + lastAccessedTime: new Date().getTime() }) + state = state.deleteIn(['ui', 'tabs', 'previewTabPageIndex']) + state = updateTabPageIndex(state, frameProps) + } } }) return state @@ -381,19 +391,6 @@ const doAction = (action) => { case windowConstants.WINDOW_CLEAR_CLOSED_FRAMES: windowState = windowState.set('closedFrames', new Immutable.List()) break - case windowConstants.WINDOW_ACTIVE_FRAME_CHANGED: - if (!action.frameProps) { - break - } - windowState = windowState.merge({ - activeFrameKey: action.frameProps.get('key'), - previewFrameKey: null - }) - windowState = windowState.mergeIn(['frames', frameStateUtil.getFramePropsIndex(frameStateUtil.getFrames(windowState), action.frameProps)], { - lastAccessedTime: new Date().getTime() }) - windowState = windowState.deleteIn(['ui', 'tabs', 'previewTabPageIndex']) - windowState = updateTabPageIndex(windowState, action.frameProps) - break case windowConstants.WINDOW_SET_PREVIEW_FRAME: windowState = windowState.merge({ previewFrameKey: action.frameProps && action.frameProps.get('key') !== windowState.get('activeFrameKey')