diff --git a/app/renderer/components/window.js b/app/renderer/components/window.js index 07a1b65e340..6bfa2f82c57 100644 --- a/app/renderer/components/window.js +++ b/app/renderer/components/window.js @@ -2,55 +2,30 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ -// Controller view which manages the top level immutable state for the app - const React = require('react') -const PropTypes = require('prop-types') const Immutable = require('immutable') // Components const Main = require('./main/main') - -// Stores -const windowStore = require('../../../js/stores/windowStore') -const appStoreRenderer = require('../../../js/stores/appStoreRenderer') +const ReduxComponent = require('./reduxComponent') // Actions -const windowActions = require('../../../js/actions/windowActions') const appActions = require('../../../js/actions/appActions') // Utils const cx = require('../../../js/lib/classSet') +const frameStateUtil = require('../../../js/state/frameStateUtil') const {getPlatformStyles} = require('../../common/lib/platformUtil') const {getCurrentWindowId} = require('../currentWindow') window.appActions = appActions class Window extends React.Component { - constructor (props) { - super(props) - // initialize appState from props - // and then listen for updates - this.appState = appStoreRenderer.state - this.windowState = Immutable.fromJS(this.props.initWindowState) || windowStore.getState() - this.state = { - immutableData: { - windowState: this.windowState, - appState: this.appState - } - } - if (this.props.initWindowState) { - windowActions.setState(this.windowState) - } - - this.onChange = this.onChange.bind(this) - this.onAppStateChange = this.onAppStateChange.bind(this) - windowStore.addChangeListener(this.onChange) - appStoreRenderer.addChangeListener(this.onAppStateChange) + componentDidMount () { + appActions.windowReady(getCurrentWindowId()) } componentWillMount () { - const activeFrameKey = this.state.immutableData.windowState.get('activeFrameKey') this.props.frames.forEach((frame, i) => { if (frame.guestInstanceId) { appActions.newWebContentsAdded(getCurrentWindowId(), frame) @@ -59,7 +34,7 @@ class Window extends React.Component { url: frame.location || frame.src || frame.provisionalLocation, partitionNumber: frame.partitionNumber, isPrivate: frame.isPrivate, - active: activeFrameKey ? frame.key === activeFrameKey : true, + active: this.props.activeFrameKey ? frame.key === this.props.activeFrameKey : true, discarded: frame.unloaded, title: frame.title, faviconUrl: frame.icon, @@ -69,7 +44,7 @@ class Window extends React.Component { }) } - render () { + get classes () { let classes = {} classes['windowContainer'] = true @@ -85,50 +60,25 @@ class Window extends React.Component { classes['inactive'] = !this.windowState.getIn(['ui', 'isFocused']) } - return