React = require 'react/addons' ReactCSSTransitionGroup = React.addons.CSSTransitionGroup OnboardingActions = require './onboarding-actions' OnboardingStore = require './onboarding-store' querystring = require 'querystring' {EdgehillAPI} = require 'nylas-exports' {RetinaImg} = require 'nylas-component-kit' class ContainerView extends React.Component @displayName: 'ContainerView' @containerRequired: false constructor: (@props) -> @state = @getStateFromStore() getStateFromStore: => page: OnboardingStore.page() error: OnboardingStore.error() environment: OnboardingStore.environment() connectType: OnboardingStore.connectType() componentDidMount: => @unsubscribe = OnboardingStore.listen(@_onStateChanged, @) # It's important that every React class explicitly stops listening to # atom events before it unmounts. Thank you event-kit # This can be fixed via a Reflux mixin componentWillUnmount: => @unsubscribe() if @unsubscribe componentDidUpdate: => webview = @refs['connect-iframe'] if webview node = React.findDOMNode(webview) if node.hasListeners is undefined # Remove as soon as possible. Initial src is not correctly loaded # on webview, and this fixes it. Electron 0.26.0 setTimeout -> node.src = node.src node.addEventListener 'new-window', (e) -> require('shell').openExternal(e.url) node.addEventListener 'did-start-loading', (e) -> if node.hasMobileUserAgent is undefined node.setUserAgent("Mozilla/5.0 (iPhone; CPU iPhone OS 7_1 like Mac OS X) AppleWebKit/537.51.2 (KHTML, like Gecko) Version/7.0 Mobile/11D167 Safari/9537.53") node.hasMobileUserAgent = true node.reload() node.addEventListener 'did-finish-load', (e) -> if node.getUrl().indexOf('/connect/complete') != -1 query = node.getUrl().split('?')[1] query = query[0..-2] if query[query.length - 1] is '#' token = querystring.decode(query) OnboardingActions.finishedConnect(token) if node.getUrl().indexOf('cancelled') != -1 OnboardingActions.moveToPreviousPage() render: =>