<commit_before>/*

`<AccountHeader>`
=================

>   For more information on the contents of this file, please contact:
>
>   - kibigo! <EMAIL>]

Original file by <EMAIL> et al as part of
tootsuite/mastodon. We've expanded it in order to handle user bio
frontmatter.

The `<AccountHeader>` component provides the header for account
timelines. It is a fairly simple component which mostly just consists
of a `render()` method.

__Props:__

 -  __`account` (`ImmutablePropTypes.map`) :__
    The account to render a header for.

 -  __`me` (`PropTypes.number.isRequired`) :__
    The id of the currently-signed-in account.

 -  __`onFollow` (`PropTypes.func.isRequired`) :__
    The function to call when the user clicks the "follow" button.

 -  __`intl` (`PropTypes.object.isRequired`) :__
    Our internationalization object, inserted by `@injectIntl`.

*/

//  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

/*

Imports:
--------

*/

//  Package imports  //
import React from 'react';
import ImmutablePropTypes from 'react-immutable-proptypes';
import PropTypes from 'prop-types';
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
import ImmutablePureComponent from 'react-immutable-pure-component';

//  Mastodon imports  //
import emojify from 'mastodon/features/emoji/emoji';
import IconButton from '../../../mastodon/components/icon_button';
import Avatar from '../../../mastodon/components/avatar';

//  Our imports  //
import { processBio } from '../../util/bio_metadata';

//  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

/*

Inital setup:
-------------

The `messages` constant is used to define any messages that we need
from inside props. In our case, these are the `unfollow`, `follow`, and
`requested` messages used in the `title` of our buttons.

*/

const messages = defineMessages({
  unfollow: { id: 'account.unfollow', defaultMessage: 'Unfollow' },
  follow: { id: 'account.follow', defaultMessage: 'Follow' },
  requested: { id: 'account.requested', defaultMessage: 'Awaiting approval' },
});

//  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

/*

Implementation:
---------------

*/

@injectIntl
export default class AccountHeader extends ImmutablePureComponent {

  static propTypes = {
    account  : ImmutablePropTypes.map,
    me       : PropTypes.string.isRequired,
    onFollow : PropTypes.func.isRequired,
    intl     : PropTypes.object.isRequired,
  };

/*

###  `render()`

The `render()` function is used to render our component.

*/

  render () {
    const { account, me, intl } = this.props;

/*

If no `account` is provided, then we can't render a header. Otherwise,
we get the `displayName` for the account, if available. If it's blank,
then we set the `displayName` to just be the `username` of the account.

*/

    if (!account) {
      return null;
    }

    let displayName = account.get('display_name_html');
    let info        = '';
    let actionBtn   = '';
    let following   = false;

    if (displayName.length === 0) {
      displayName = account.get('username');
    }

/*

Next, we handle the account relationships. If the account follows the
user, then we add an `info` message. If the user has requested a
follow, then we disable the `actionBtn` and display an hourglass.
Otherwise, if the account isn't blocked, we set the `actionBtn` to the
appropriate icon.

*/

    if (me !== account.get('id')) {
      if (account.getIn(['relationship', 'followed_by'])) {
        info = (
          <span className='account--follows-info'>
            <FormattedMessage id='account.follows_you' defaultMessage='Follows you' />
          </span>
        );
      }
      if (account.getIn(['relationship', 'requested'])) {
        actionBtn = (
          <div className='account--action-button'><commit_msg>Removed length check which now happens in reducer<commit_after>/*

`<AccountHeader>`
=================

>   For more information on the contents of this file, please contact:
>
>   - kibigo! <EMAIL>]

Original file by <EMAIL> et al as part of
tootsuite/mastodon. We've expanded it in order to handle user bio
frontmatter.

The `<AccountHeader>` component provides the header for account
timelines. It is a fairly simple component which mostly just consists
of a `render()` method.

__Props:__

 -  __`account` (`ImmutablePropTypes.map`) :__
    The account to render a header for.

 -  __`me` (`PropTypes.number.isRequired`) :__
    The id of the currently-signed-in account.

 -  __`onFollow` (`PropTypes.func.isRequired`) :__
    The function to call when the user clicks the "follow" button.

 -  __`intl` (`PropTypes.object.isRequired`) :__
    Our internationalization object, inserted by `@injectIntl`.

*/

//  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

/*

Imports:
--------

*/

//  Package imports  //
import React from 'react';
import ImmutablePropTypes from 'react-immutable-proptypes';
import PropTypes from 'prop-types';
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
import ImmutablePureComponent from 'react-immutable-pure-component';

//  Mastodon imports  //
import emojify from 'mastodon/features/emoji/emoji';
import IconButton from '../../../mastodon/components/icon_button';
import Avatar from '../../../mastodon/components/avatar';

//  Our imports  //
import { processBio } from '../../util/bio_metadata';

//  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

/*

Inital setup:
-------------

The `messages` constant is used to define any messages that we need
from inside props. In our case, these are the `unfollow`, `follow`, and
`requested` messages used in the `title` of our buttons.

*/

const messages = defineMessages({
  unfollow: { id: 'account.unfollow', defaultMessage: 'Unfollow' },
  follow: { id: 'account.follow', defaultMessage: 'Follow' },
  requested: { id: 'account.requested', defaultMessage: 'Awaiting approval' },
});

//  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

/*

Implementation:
---------------

*/

@injectIntl
export default class AccountHeader extends ImmutablePureComponent {

  static propTypes = {
    account  : ImmutablePropTypes.map,
    me       : PropTypes.string.isRequired,
    onFollow : PropTypes.func.isRequired,
    intl     : PropTypes.object.isRequired,
  };

/*

###  `render()`

The `render()` function is used to render our component.

*/

  render () {
    const { account, me, intl } = this.props;

/*

If no `account` is provided, then we can't render a header. Otherwise,
we get the `displayName` for the account, if available. If it's blank,
then we set the `displayName` to just be the `username` of the account.

*/

    if (!account) {
      return null;
    }

    let displayName = account.get('display_name_html');
    let info        = '';
    let actionBtn   = '';
    let following   = false;

/*

Next, we handle the account relationships. If the account follows the
user, then we add an `info` message. If the user has requested a
follow, then we disable the `actionBtn` and display an hourglass.
Otherwise, if the account isn't blocked, we set the `actionBtn` to the
appropriate icon.

*/

    if (me !== account.get('id')) {
      if (account.getIn(['relationship', 'followed_by'])) {
        info = (
          <span className='account--follows-info'>
            <FormattedMessage id='account.follows_you' defaultMessage='Follows you' />
          </span>
        );
      }
      if (account.getIn(['relationship', 'requested'])) {
        actionBtn = (
          <div className='account--action-button'>
{'fraction_non_alphanumeric': 0.15608672936259144, 'fraction_numerical': 0.00013061650992685477, 'mean_word_length': 2.959152016546019, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 24, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6534608', 'n_tokens_mistral': 2402, 'n_tokens_neox': 2347, 'n_words': 709}