React = require 'react' ReactDOM = require 'react-dom' ReactCSSTransitionGroup = require 'react-addons-css-transition-group' OnboardingActions = require './onboarding-actions' PageRouterStore = require './page-router-store' WelcomePage = require './welcome-page' AccountChoosePage = require './account-choose-page' AccountSettingsPage = require './account-settings-page' InitialPreferencesPage = require './initial-preferences-page' InitialPackagesPage = require './initial-packages-page' TokenAuthPage = require './token-auth-page' class PageRouter extends React.Component @displayName: 'PageRouter' @containerRequired: false constructor: (@props) -> @state = @_getStateFromStore() window.OnboardingActions = OnboardingActions _getStateFromStore: => page: PageRouterStore.page() pageData: PageRouterStore.pageData() componentDidMount: => @unsubscribe = PageRouterStore.listen(@_onStateChanged, @) setTimeout(@_initializeWindowSize, 10) componentDidUpdate: => setTimeout(@_updateWindowSize, 10) _initializeWindowSize: => return if @_unmounted {width, height} = ReactDOM.findDOMNode(@refs.activePage).getBoundingClientRect() NylasEnv.setSize(width, height) NylasEnv.center() NylasEnv.displayWindow() _updateWindowSize: => return if @_unmounted {width, height} = ReactDOM.findDOMNode(@refs.activePage).getBoundingClientRect() NylasEnv.setSizeAnimated(width, height) _onStateChanged: => @setState(@_getStateFromStore()) componentWillUnmount: => @_unmounted = true @unsubscribe?() render: =>