React = require 'react' {Actions, AccountStore} = require("nylas-exports") {RetinaImg} = require('nylas-component-kit') crypto = require 'crypto' classNames = require 'classnames' class AccountSwitcher extends React.Component @displayName: 'AccountSwitcher' @containerRequired: false @containerStyles: minWidth: 64 maxWidth: 64 constructor: (@props) -> @state = @_getStateFromStores() componentDidMount: => @unsubscribers = [] @unsubscribers.push AccountStore.listen @_onStoreChange # 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() for unsubscribe in @unsubscribers render: => if @state.accounts.length is 0 return