_ = require 'underscore'
path = require 'path'
React = require 'react'
classNames = require 'classnames'
{RetinaImg, TimeoutTransitionGroup} = require 'nylas-component-kit'
{Actions,
Utils,
ComponentRegistry,
UndoRedoStore,
NamespaceStore} = require 'nylas-exports'
class UndoRedoComponent extends React.Component
@displayName: 'UndoRedoComponent'
@propTypes:
task: React.PropTypes.object.isRequired
show: React.PropTypes.bool
constructor: (@props) ->
@state = @_getStateFromStores()
@_timeout = null
_onChange: =>
@setState(@_getStateFromStores(), =>
@_setNewTimeout())
_clearTimeout: =>
clearTimeout(@_timeout)
_setNewTimeout: =>
clearTimeout(@_timeout)
@_timeout = setTimeout (=>
@_hide()
return
), 3000
_getStateFromStores: ->
t = UndoRedoStore.getMostRecentTask()
s = false
if t
s = true
return {show: s, task: t}
componentWillMount: ->
@unsub = UndoRedoStore.listen(@_onChange)
componentWillUnmount: ->
@unsub()
render: =>
items = [].concat(@_renderUndoRedoManager())
names = classNames
"undo-redo-manager": true
{@_formatMessage()}
Undo