<commit_before>import { connect } from 'react-redux';
import formatNumber from 'ringcentral-integration/lib/formatNumber';
import ComposeTextPanel from '../../components/ComposeTextPanel';
import withPhone from '../../lib/withPhone';

function mapToProps(_, {
  phone: {
    composeText,
    connectivityMonitor,
    contactSearch,
    locale,
    messageSender,
    rateLimiter,
    rolesAndPermissions,
    brand
  },
}) {
  return {
    brand: brand.fullName,
    currentLocale: locale.currentLocale,
    sendButtonDisabled: (
      !(composeText.ready && messageSender.idle) ||
      (composeText.messageText.length === 0) ||
      (
        composeText.toNumbers.length === 0 &&
        composeText.typingToNumber.length === 0
      ) ||
      !connectivityMonitor.connectivity ||
      rateLimiter.throttling
    ),
    senderNumbers: messageSender.senderNumbersList,
    senderNumber: composeText.senderNumber,
    typingToNumber: composeText.typingToNumber,
    toNumbers: composeText.toNumbers,
    messageText: composeText.messageText,
    outboundSMS: rolesAndPermissions.permissions.OutboundSMS,
    searchContactList: contactSearch.sortedResult,
    showSpinner: !(
      composeText.ready &&
      locale.ready &&
      messageSender.ready &&
      rolesAndPermissions.ready &&
      contactSearch.ready
    ),
  };
}

function mapToFunctions(_, {
  phone: {
    composeText,
    contactSearch,
    messageStore,
    regionSettings,
    routerInteraction,
  },
  formatContactPhone = phoneNumber => formatNumber({
    phoneNumber,
    areaCode: regionSettings.areaCode,
    countryCode: regionSettings.countryCode,
  }),
  phoneTypeRenderer,
  recipientsContactInfoRenderer,
  recipientsContactPhoneRenderer,
}) {
  return {
    send: () => {
      let timeout = setTimeout(() => {
        if (routerInteraction.currentPath === '/composeText') {
          composeText.alertMessageSending();
        }
        if (timeout) {
          clearTimeout(timeout);
          timeout = null;
        }
      }, 10000);
      composeText.send().then((responses) => {
        if (timeout) {
          clearTimeout(timeout);
          timeout = null;<commit_msg>fix message sender alert `alertMessageSending` (#846)<commit_after>import { connect } from 'react-redux';
import formatNumber from 'ringcentral-integration/lib/formatNumber';
import messageSenderMessages from 'ringcentral-integration/modules/MessageSender/messageSenderMessages';
import ComposeTextPanel from '../../components/ComposeTextPanel';
import withPhone from '../../lib/withPhone';

function mapToProps(_, {
  phone: {
    composeText,
    connectivityMonitor,
    contactSearch,
    locale,
    messageSender,
    rateLimiter,
    rolesAndPermissions,
    brand
  },
}) {
  return {
    brand: brand.fullName,
    currentLocale: locale.currentLocale,
    sendButtonDisabled: (
      !(composeText.ready && messageSender.idle) ||
      (composeText.messageText.length === 0) ||
      (
        composeText.toNumbers.length === 0 &&
        composeText.typingToNumber.length === 0
      ) ||
      !connectivityMonitor.connectivity ||
      rateLimiter.throttling
    ),
    senderNumbers: messageSender.senderNumbersList,
    senderNumber: composeText.senderNumber,
    typingToNumber: composeText.typingToNumber,
    toNumbers: composeText.toNumbers,
    messageText: composeText.messageText,
    outboundSMS: rolesAndPermissions.permissions.OutboundSMS,
    searchContactList: contactSearch.sortedResult,
    showSpinner: !(
      composeText.ready &&
      locale.ready &&
      messageSender.ready &&
      rolesAndPermissions.ready &&
      contactSearch.ready
    ),
  };
}

function mapToFunctions(_, {
  phone: {
    composeText,
    contactSearch,
    messageStore,
    regionSettings,
    routerInteraction,
    alert,
  },
  formatContactPhone = phoneNumber => formatNumber({
    phoneNumber,
    areaCode: regionSettings.areaCode,
    countryCode: regionSettings.countryCode,
  }),
  phoneTypeRenderer,
  recipientsContactInfoRenderer,
  recipientsContactPhoneRenderer,
}) {
  return {
    send: () => {
      let timeout = setTimeout(() => {
        if (routerInteraction.currentPath === '/composeText') {
          const hasAlertOtherMsg = alert.messages.filter(({ level, message }) => (
            level === 'warning' &&
            Object.values(messageSenderMessages).indexOf(message) > -1
          )).length > 0;
          if (!hasAlertOtherMsg) composeText.alertMessageSending();
        }
        if (timeout) {
          clearTimeout(timeout);
          timeout = null;
        }
      }, 10000);
      composeText.send().then((responses) => {
        if (timeout) {
          clearTimeout(timeout);
          timeout = null;
{'fraction_non_alphanumeric': 0.11099343359457742, 'fraction_numerical': 0.004448210124973522, 'mean_word_length': 3.0153061224489797, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2891848', 'n_tokens_mistral': 1351, 'n_tokens_neox': 1324, 'n_words': 228}