<commit_before>// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.

const FileAttachmentList = require('./file_attachment_list.jsx');
const UserStore = require('../stores/user_store.jsx');
const Utils = require('../utils/utils.jsx');
const Constants = require('../utils/constants.jsx');
const TextFormatting = require('../utils/text_formatting.jsx');
const twemoji = require('twemoji');
const PostBodyAdditionalContent = require('./post_body_additional_content.jsx');

export default class PostBody extends React.Component {
    constructor(props) {
        super(props);

        this.receivedYoutubeData = false;
        this.isGifLoading = false;

        this.parseEmojis = this.parseEmojis.bind(this);
        this.createEmbed = this.createEmbed.bind(this);
        this.createGifEmbed = this.createGifEmbed.bind(this);
        this.loadGif = this.loadGif.bind(this);
        this.createYoutubeEmbed = this.createYoutubeEmbed.bind(this);

        const linkData = Utils.extractLinks(this.props.post.message);
        this.state = {links: linkData.links, message: linkData.text};
    }

    getAllChildNodes(nodeIn) {
        var textNodes = [];

        function getTextNodes(node) {
            textNodes.push(node);

            for (var i = 0, len = node.childNodes.length; i < len; ++i) {
                getTextNodes(node.childNodes[i]);
            }
        }

        getTextNodes(nodeIn);
        return textNodes;
    }

    parseEmojis() {
        twemoji.parse(ReactDOM.findDOMNode(this), {size: Constants.EMOJI_SIZE});
    }

    componentDidMount() {
        this.parseEmojis();
    }

    componentDidUpdate() {
        this.parseEmojis();
    }

    componentWillReceiveProps(nextProps) {<commit_msg>Updated post components to re-render after first receiving user profiles<commit_after>// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.

const FileAttachmentList = require('./file_attachment_list.jsx');
const UserStore = require('../stores/user_store.jsx');
const Utils = require('../utils/utils.jsx');
const Constants = require('../utils/constants.jsx');
const TextFormatting = require('../utils/text_formatting.jsx');
const twemoji = require('twemoji');
const PostBodyAdditionalContent = require('./post_body_additional_content.jsx');

export default class PostBody extends React.Component {
    constructor(props) {
        super(props);

        this.receivedYoutubeData = false;
        this.isGifLoading = false;

        this.handleUserChange = this.handleUserChange.bind(this);
        this.parseEmojis = this.parseEmojis.bind(this);
        this.createEmbed = this.createEmbed.bind(this);
        this.createGifEmbed = this.createGifEmbed.bind(this);
        this.loadGif = this.loadGif.bind(this);
        this.createYoutubeEmbed = this.createYoutubeEmbed.bind(this);

        const linkData = Utils.extractLinks(this.props.post.message);
        const profiles = UserStore.getProfiles();

        this.state = {
            links: linkData.links,
            message: linkData.text,
            hasUserProfiles: profiles && Object.keys(profiles).length > 1
        };
    }

    getAllChildNodes(nodeIn) {
        var textNodes = [];

        function getTextNodes(node) {
            textNodes.push(node);

            for (var i = 0, len = node.childNodes.length; i < len; ++i) {
                getTextNodes(node.childNodes[i]);
            }
        }

        getTextNodes(nodeIn);
        return textNodes;
    }

    parseEmojis() {
        twemoji.parse(ReactDOM.findDOMNode(this), {size: Constants.EMOJI_SIZE});
    }

    componentDidMount() {
        this.parseEmojis();

        UserStore.addChangeListener(this.handleUserChange);
    }

    componentDidUpdate() {
        this.parseEmojis();
    }

    componentWillUnmount() {
        UserStore.removeChangeListener(this.handleUserChange);
    }

    handleUserChange() {
        if (!this.state.hasProfiles) {
            const profiles = UserStore.getProfiles();

            this.setState({hasProfiles: profiles && Object.keys(profiles).length > 1});
        }
    }

    componentWillReceiveProps(nextProps) {
{'fraction_non_alphanumeric': 0.12241992882562278, 'fraction_numerical': 0.0028469750889679717, 'mean_word_length': 2.8223028105167725, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '4535186', 'n_tokens_mistral': 1289, 'n_tokens_neox': 1232, 'n_words': 217}