fix(pref): check for mounting on async launch service

This commit is contained in:
Evan Morikawa 2016-01-29 17:11:54 -08:00
parent 00c1645300
commit 0d0cd0c58d

View file

@ -9,7 +9,13 @@ class DefaultMailClientItem extends React.Component
@_services = new LaunchServices() @_services = new LaunchServices()
if @_services.available() if @_services.available()
@_services.isRegisteredForURLScheme 'mailto', (registered) => @_services.isRegisteredForURLScheme 'mailto', (registered) =>
@setState(defaultClient: registered) @setState(defaultClient: registered) if @_mounted
componentDidMount: ->
@_mounted = true
componentWillUnmount: ->
@_mounted = false
render: => render: =>
return false unless process.platform is 'darwin' return false unless process.platform is 'darwin'
@ -36,11 +42,15 @@ class LaunchSystemStartItem extends React.Component
@_service = new SystemStartService() @_service = new SystemStartService()
componentDidMount: -> componentDidMount: ->
@_mounted = true
@_service.checkAvailability().then (available) => @_service.checkAvailability().then (available) =>
@setState {available} @setState {available} if @_mounted
return if not available return if not available or not @_mounted
@_service.doesLaunchOnSystemStart().then (launchOnStart) => @_service.doesLaunchOnSystemStart().then (launchOnStart) =>
@setState({launchOnStart}) @setState({launchOnStart}) if @_mounted
componentWillUnmount: ->
@_mounted = false
render: => render: =>
return false if not @state.available return false if not @state.available