_ = require 'underscore' path = require 'path' React = require 'react' classNames = require 'classnames' {RetinaImg, TimeoutTransitionGroup} = require 'nylas-component-kit' {Actions, Utils, ComponentRegistry, UndoRedoStore, AccountStore} = require 'nylas-exports' class UndoRedoComponent extends React.Component @displayName: 'UndoRedoComponent' @containerRequired: false constructor: (@props) -> @state = @_getStateFromStores() @_timeout = null _onChange: => @setState(@_getStateFromStores(), => @_setNewTimeout()) _clearTimeout: => clearTimeout(@_timeout) _setNewTimeout: => @_clearTimeout() @_timeout = setTimeout (=> @_hide() return ), 3000 _getStateFromStores: -> tasks = UndoRedoStore.getMostRecent() show = false if tasks show = true return {show, tasks} componentWillMount: -> @_unsubscribe = UndoRedoStore.listen(@_onChange) componentWillUnmount: -> @_clearTimeout() @_unsubscribe() render: => inner = @_renderUndoRedoManager() names = classNames "undo-redo-manager": true {inner} _renderUndoRedoManager: => if @state.show
{@state.tasks.map((t) -> t.description()).join(', ')}
Undo
else [] _onClick: => NylasEnv.commands.dispatch(document.querySelector('body'), 'core:undo') @_hide() _hide: => @setState({show: false, tasks: null}) module.exports = UndoRedoComponent