fix(important): Resilient against invalid AccountStore state (Sentry 4049)

This commit is contained in:
Ben Gotow 2015-10-22 16:05:33 -07:00
parent 8b8c333ad8
commit c914b2701b

View file

@ -13,14 +13,14 @@ class MailImportantIcon extends React.Component
thread: React.PropTypes.object
constructor: (@props) ->
@state = @getStateFromStores()
@state = @getState()
getStateFromStores: =>
showing: AccountStore.current().usesImportantFlag() and atom.config.get('core.showImportant')
getState: =>
showing: AccountStore.current()?.usesImportantFlag() and atom.config.get('core.showImportant')
componentDidMount: =>
@subscription = atom.config.observe 'core.showImportant', =>
@setState(@getStateFromStores())
@setState(@getState())
componentWillUnmount: =>
@subscription?.dispose()