 {relative, join} = require 'path-extra'
 {$, _, $$, React, ReactBootstrap, FontAwesome, ROOT} = window
 {Alert, Button, ButtonGroup, Col, Grid, Input, OverlayTrigger, Tooltip} = ReactBootstrap
+scheduler = require 'views/services/scheduler'
 
 
 # i18n

convertFilename = (shipId, voiceId) ->
  return (shipId + 7) * 17 * (vcKey[voiceId] - vcKey[voiceId - 1]) % 99173 + 100000

SecretaryArea = React.createClass
  getInitialState: ->
    # Load game data from localStorage.

    window.removeEventListener 'secretary.unload', @pluginWillUnload

  pluginDidLoad: ->
    hourly_notify()
    nextHour = new Date()
    nextHour.setHours nextHour.getHours()+1
    nextHour.setMinutes 0
    nextHour.setSeconds 0
    scheduler.schedule hourly_notify,
      time: nextHour.getTime()
      interval: 1000 * 60 *60
      allowImmediate: true
    console.log("scheduled hourly notify, next notify: #{nextHour.toString()}")
    if @state.notifySecretary > 0
      @updateNotifyConfig(@state.notifySecretary)

