<commit_before>var ActivityFeedComment = require('../activity_feed_comment.js.jsx');
var AppIcon = require('../app_icon.js.jsx');
var ArchivedNewsFeedItemsStore = require('../../stores/archived_news_feed_items_store');
var Avatar = require('../ui/avatar.js.jsx');
var Bounty = require('../bounty.js.jsx')
var Comment = require('../comment.js.jsx');
var Discussion = require('../ui/discussion.js.jsx')
var Heart = require('../heart.js.jsx');
var Introduction = require('../introduction.js.jsx')
var Lightbox = require('../lightbox.js.jsx')
var Markdown = require('../markdown.js.jsx');
var moment = require('moment');
var NewsFeedItemActionCreators = require('../../actions/news_feed_item_action_creators');
var NewsFeedItemBounty = require('./news_feed_item_bounty.js.jsx');
var NewsFeedItemBountyModal = require('./news_feed_item_bounty_modal.js.jsx');
var NewsFeedItemIntroduction = require('./news_feed_item_introduction.js.jsx');
var NewsFeedItemModal = require('./news_feed_item_modal.js.jsx');
var NewsFeedItemPost = require('./news_feed_item_post.js.jsx');
var SubscriptionsStore = require('../../stores/subscriptions_store');
var Tag = require('../tag.js.jsx');
var Tile = require('../tile.js.jsx');
var Update = require('../update.js.jsx')
var UserStore = require('../../stores/user_store');

var ONE_DAY = 24 * 60 * 60 * 1000;

var NewsFeedItem = React.createClass({
  displayName: 'NewsFeedItem',

  propTypes: {
    commentable: React.PropTypes.bool,
    enableModal: React.PropTypes.bool,
    productPage: React.PropTypes.bool,
    product: React.PropTypes.object.isRequired,
    showAllComments: React.PropTypes.bool,
    target: React.PropTypes.object,
    user: React.PropTypes.object.isRequired
  },

  typeMap: {
    task: 'bounty',
    team_membership: 'team member',
    news_feed_item_post: 'update'
  },

  componentDidMount: function() {
    ArchivedNewsFeedItemsStore.addChangeListener(this.getStateFromStore);
    SubscriptionsStore.addChangeListener(this.getStateFromStore);
  },

  componentWillUnmount: function() {
    ArchivedNewsFeedItemsStore.removeChangeListener(this.getStateFromStore);
    SubscriptionsStore.removeChangeListener(this.getStateFromStore);
  },

  getDefaultProps: function() {
    return {
      enableModal: true,
      productPage: false
    };
  },

  getInitialState: function() {
    var id = this.props.id;

    return {
      isArchived: ArchivedNewsFeedItemsStore.isArchived(id),
      isSubscribed: SubscriptionsStore.isSubscribed(id),
      modalShown: false
    };
  },

  getStateFromStore: function() {
    var target = this.props.target;

    if (target && target.type === 'post') {
      this.setState({
        isArchived: ArchivedNewsFeedItemsStore.isArchived(this.props.id),
        isSubscribed: SubscriptionsStore.isSubscribed(this.props.id)
      });
    }
  },

  handleArchive: function() {
    var productSlug = this.props.product.slug;
    var itemId = this.props.id;

    if (this.state.isArchived) {
      NewsFeedItemActionCreators.unarchive(productSlug, itemId);
    } else {
      NewsFeedItemActionCreators.archive(productSlug, itemId);
    }
  },

  handleSubscribe: function() {
    var productSlug = this.props.product.slug;
    var itemId = this.props.id;

    if (this.state.isSubscribed) {
      NewsFeedItemActionCreators.unsubscribe(productSlug, itemId);
    } else {
      NewsFeedItemActionCreators.subscribe(productSlug, itemId);
    }
  },

  onModalHidden: function() {
    this.setState({
      modalShown: false
    });
  },

  render: function() {
    return (
      <Tile>
        {this.props.productPage ? null : this.renderSource()}
        {this.renderTarget()}
        {this.props.enableModal && this.state.modalShown ? this.renderModal() : null}
        {this.renderMeta()}
        {this.renderUserSource()}
        {this.renderLove()}
        {this.renderFooter()}
        {this.renderComments()}
      </Tile>
    );
  },

  renderArchiveButton: function() {
    if (!UserStore.isCoreTeam()) {
      return;
    }

    // only turn on for posts
    if (this.props.target && this.props.target.type === 'post') {
      var text = 'Archive';
      if (this.state.isArchived) {
        text = 'Unarchive';
      }

      return (
        <li>
          <a href="javascript:void(0);" onClick={this.handleArchive}>{text}</a>
        </li>
      );
    }
  },

  renderComments: function() {
    var comment = this.props.last_comment
    if (comment) {
      return <div className="px3">
        <ActivityFeedComment author={comment.user} body={comment.body} heartable={false} />
      </div>
    }
  },

  renderEditButton: function() {
    if (UserStore.isCoreTeam() || this.props.user.id === UserStore.getId()) {
      var target = this.props.target;

      // only turn on for posts
      if (target && target.type === 'post') {
        return (
          <li>
            <a href={target.url + '/edit'}>Edit</a>
          </li>
        );
      }
    }
  },
<commit_msg>Include embedded images in news feed item comments<commit_after>var ActivityFeedComment = require('../activity_feed_comment.js.jsx');
var AppIcon = require('../app_icon.js.jsx');
var ArchivedNewsFeedItemsStore = require('../../stores/archived_news_feed_items_store');
var Avatar = require('../ui/avatar.js.jsx');
var Bounty = require('../bounty.js.jsx')
var Comment = require('../comment.js.jsx');
var Discussion = require('../ui/discussion.js.jsx')
var Heart = require('../heart.js.jsx');
var Introduction = require('../introduction.js.jsx')
var Lightbox = require('../lightbox.js.jsx')
var Markdown = require('../markdown.js.jsx');
var moment = require('moment');
var NewsFeedItemActionCreators = require('../../actions/news_feed_item_action_creators');
var NewsFeedItemBounty = require('./news_feed_item_bounty.js.jsx');
var NewsFeedItemBountyModal = require('./news_feed_item_bounty_modal.js.jsx');
var NewsFeedItemIntroduction = require('./news_feed_item_introduction.js.jsx');
var NewsFeedItemModal = require('./news_feed_item_modal.js.jsx');
var NewsFeedItemPost = require('./news_feed_item_post.js.jsx');
var SubscriptionsStore = require('../../stores/subscriptions_store');
var Tag = require('../tag.js.jsx');
var Tile = require('../tile.js.jsx');
var Update = require('../update.js.jsx')
var UserStore = require('../../stores/user_store');

var ONE_DAY = 24 * 60 * 60 * 1000;

var NewsFeedItem = React.createClass({
  displayName: 'NewsFeedItem',

  propTypes: {
    commentable: React.PropTypes.bool,
    enableModal: React.PropTypes.bool,
    productPage: React.PropTypes.bool,
    product: React.PropTypes.object.isRequired,
    showAllComments: React.PropTypes.bool,
    target: React.PropTypes.object,
    user: React.PropTypes.object.isRequired
  },

  typeMap: {
    task: 'bounty',
    team_membership: 'team member',
    news_feed_item_post: 'update'
  },

  componentDidMount: function() {
    ArchivedNewsFeedItemsStore.addChangeListener(this.getStateFromStore);
    SubscriptionsStore.addChangeListener(this.getStateFromStore);
  },

  componentWillUnmount: function() {
    ArchivedNewsFeedItemsStore.removeChangeListener(this.getStateFromStore);
    SubscriptionsStore.removeChangeListener(this.getStateFromStore);
  },

  getDefaultProps: function() {
    return {
      enableModal: true,
      productPage: false
    };
  },

  getInitialState: function() {
    var id = this.props.id;

    return {
      isArchived: ArchivedNewsFeedItemsStore.isArchived(id),
      isSubscribed: SubscriptionsStore.isSubscribed(id),
      modalShown: false
    };
  },

  getStateFromStore: function() {
    var target = this.props.target;

    if (target && target.type === 'post') {
      this.setState({
        isArchived: ArchivedNewsFeedItemsStore.isArchived(this.props.id),
        isSubscribed: SubscriptionsStore.isSubscribed(this.props.id)
      });
    }
  },

  handleArchive: function() {
    var productSlug = this.props.product.slug;
    var itemId = this.props.id;

    if (this.state.isArchived) {
      NewsFeedItemActionCreators.unarchive(productSlug, itemId);
    } else {
      NewsFeedItemActionCreators.archive(productSlug, itemId);
    }
  },

  handleSubscribe: function() {
    var productSlug = this.props.product.slug;
    var itemId = this.props.id;

    if (this.state.isSubscribed) {
      NewsFeedItemActionCreators.unsubscribe(productSlug, itemId);
    } else {
      NewsFeedItemActionCreators.subscribe(productSlug, itemId);
    }
  },

  onModalHidden: function() {
    this.setState({
      modalShown: false
    });
  },

  render: function() {
    return (
      <Tile>
        {this.props.productPage ? null : this.renderSource()}
        {this.renderTarget()}
        {this.props.enableModal && this.state.modalShown ? this.renderModal() : null}
        {this.renderMeta()}
        {this.renderUserSource()}
        {this.renderLove()}
        {this.renderFooter()}
        {this.renderComments()}
      </Tile>
    );
  },

  renderArchiveButton: function() {
    if (!UserStore.isCoreTeam()) {
      return;
    }

    // only turn on for posts
    if (this.props.target && this.props.target.type === 'post') {
      var text = 'Archive';
      if (this.state.isArchived) {
        text = 'Unarchive';
      }

      return (
        <li>
          <a href="javascript:void(0);" onClick={this.handleArchive}>{text}</a>
        </li>
      );
    }
  },

  renderComments: function() {
    var comment = this.props.last_comment
    if (comment) {
      return <div className="px3">
        <ActivityFeedComment author={comment.user} body={comment.markdown_body} heartable={false} />
      </div>
    }
  },

  renderEditButton: function() {
    if (UserStore.isCoreTeam() || this.props.user.id === UserStore.getId()) {
      var target = this.props.target;

      // only turn on for posts
      if (target && target.type === 'post') {
        return (
          <li>
            <a href={target.url + '/edit'}>Edit</a>
          </li>
        );
      }
    }
  },

{'fraction_non_alphanumeric': 0.14748849309585751, 'fraction_numerical': 0.0024014408645187113, 'mean_word_length': 3.1785117056856187, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, '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': '3402384', 'n_tokens_mistral': 3215, 'n_tokens_neox': 3135, 'n_words': 533}