import React from 'react'; import PropTypes from 'prop-types'; import { Actions } from 'mailspring-exports'; import { KeyCommandsRegion, UndoToast, ListensToFluxStore } from 'nylas-component-kit'; import UndoSendStore from './undo-send-store'; class UndoSendToast extends React.Component { static displayName = 'UndoSendToast'; static propTypes = { visible: PropTypes.bool, sendActionTaskId: PropTypes.string, }; _onUndo = () => { Actions.cancelTask(this.props.sendActionTaskId); }; render() { const { visible } = this.props; return ( { if (!visible) { return; } event.preventDefault(); event.stopPropagation(); this._onUndo(); }, }} > ); } } export default ListensToFluxStore(UndoSendToast, { stores: [UndoSendStore], getStateFromStores() { return { visible: UndoSendStore.shouldShowUndoSend(), sendActionTaskId: UndoSendStore.sendActionTaskId(), }; }, });