 
 module.exports =
   reactClass: SecretaryArea
-  pluginDidLoad: ->
-    window.dispatchEvent new Event 'secretary.load'
-  pluginDidUnload: ->
+  pluginWillUnload: ->
     window.dispatchEvent new Event 'secretary.unload'

    return unless ship_id > 0
    admiral_id = parseInt(window._nickNameId) || 0
    server = SERVERS[(ship_id + admiral_id) % SERVERS.length]
    shipFilename = @state.shipgraph[ship_id]?.api_filename
    return unless server
    return unless shipFilename
    for key, id of CONFIG

    shipgraph: shipgraph
  componentDidMount: ->
    window.addEventListener 'game.response', @handleResponse
    window.addEventListener 'secretary.unload', @pluginWillUnload
    @pluginDidLoad()
  componentWillUnmount: ->
    window.removeEventListener 'game.response', @handleResponse
    window.removeEventListener 'secretary.unload', @pluginWillUnload

  pluginDidLoad: ->
    if @state.notifySecretary > 0
      @updateNotifyConfig(@state.notifySecretary)

  pluginWillUnload: ->
    for key, id of CONFIG
      config.set(key)

  handleResponse: (e) ->
    {method, path, body, postBody} = e.detail
