import { React, PropTypes, Actions, SendActionsStore, SoundRegistry } from 'mailspring-exports';
import { Menu, RetinaImg, ButtonDropdown, ListensToFluxStore } from 'mailspring-component-kit';
class SendActionButton extends React.Component {
static displayName = 'SendActionButton';
static containerRequired = false;
static propTypes = {
draft: PropTypes.object,
isValidDraft: PropTypes.func,
sendActions: PropTypes.array,
};
/* This component is re-rendered constantly because `draft` changes in random ways.
We only use the draft prop when you click send, so update with more discretion. */
shouldComponentUpdate(nextProps) {
return (
nextProps.sendActions.map(a => a.configKey).join(',') !==
this.props.sendActions.map(a => a.configKey).join(',')
);
}
primarySend() {
this._onPrimaryClick();
}
_onPrimaryClick = () => {
this._onSendWithAction(this.props.sendActions[0]);
};
_onSendWithAction = sendAction => {
if (this.props.isValidDraft()) {
if (AppEnv.config.get('core.sending.sounds')) {
SoundRegistry.playSound('hit-send');
}
Actions.sendDraft(this.props.draft.headerMessageId, { actionKey: sendAction.configKey });
}
};
_renderSendActionItem = ({ iconUrl }) => {
let plusHTML = '';
let additionalImg = false;
if (iconUrl) {
plusHTML = + ;
additionalImg =