<commit_before>import React, { Component } from 'react';
import { Actions } from 'react-native-router-flux';
import { View, TouchableOpacity, Linking } from 'react-native';
import { Text, Left, Right, Body, CardItem, Label, Icon, Thumbnail } from 'native-base';
import { parseString } from 'react-native-xml2js';
import ParsedText from './ParsedText';
import styles from '../styles';

class FeedDescription extends Component {
  redirect(item, options, scene = 'itemDetail') {
      let type;
      if (item.poll) {
          type = 'poll';
      } else if (item.post) {
          type = 'post';
      } else if (item.user_petition) {
          type = 'user-petition';
      }
      Actions[scene]({ entityType: type, entityId: item.entity.id, ...options });
  }

    _renderTitle (item) {
        if (item.title) {
            return (<Text style={styles.title}>{item.title}</Text>);
        } else {
            return null;
        }
  }
  // The priority zone counter lists the count of total priority zone items in the newsfeed
  _renderZoneIcon(item) {
    if (item.zone === 'prioritized') {
      return (<Icon active name='ios-flash' style={styles.zoneIcon} />);
    } else {
      return null;
    }
  }

  _renderAttachedImage(item){
    // console.log(item);
    let imgURL;
    let blur;
    if (item.post){
        imgURL = item.post.image;
    } else if (item.user_petition) {
        imgURL = item.user_petition.image;
    }
    if (!imgURL) return;

    if (item.user.follow_status === 'active'){
      blur = '0';
    } else if (item.user.id !== this.props.profile.id){
      blur = '1000';
    }
    return (
      <View>
        <Thumbnail medium square
          source={{uri: imgURL +`&w=400&h=400&blur=${blur}&auto=compress,format,q=95`}}
          />
      </View>);
    }
  

  handleUrlPress = url => {
    Linking.openURL(url);
  }

  handleUserPress = user => {
    try {
      const html = this.props.item.description_html;
      parseString(`<body>${html}</body>`, function (err, result) {
          result.body.a.forEach(value => {
            if (value._ === user) {
              Actions.profile({ id: value.$['data-user-id'] });
              return;
            }
          })
      });
    } catch(err) {

    }
  }

  handleHashtagPress = hashtag => {
    Actions.search({ search: hashtag.substring(1), initialPage: 2 });
  }

  render() {
    let { item } = this.props;

    return (
      <CardItem style={{ paddingLeft: 15, paddingRight: 15 }}>
        <Left>
          <View style={styles.descLeftContainer}>
            {this._renderZoneIcon(item)}
            <Label style={styles.commentCount}>{item.responses_count}</Label>
          </View>
          <Body style={styles.descBodyContainer}>
            <TouchableOpacity onPress={() => this.redirect(item)}>
              {this._renderTitle(item)}
              <ParsedText
                style={styles.description}
                parse={
                  [
                    { type: 'url', style: styles.url, onPress: this.handleUrlPress },
                    { pattern: /@(\w+)/, style: styles.username, onPress: this.handleUserPress },
                    { pattern: /#(\w+)/, style: styles.hashtag, onPress: this.handleHashtagPress },
                  ]
                }
                numberOfLines={5}
                childrenProps={{ allowFontScaling: false }}
              >
                {item.description}
              </ParsedText>
            </TouchableOpacity>
          </Body>
          <View style={{width: 80, marginRight: 0, justifyContent: 'flex-end', alignItems: 'center', alignSelf: 'flex-end'}} >
            {this._renderAttachedImage(item)}
          </View>
        </Left>
      </CardItem>
    );
  }
}
export default FeedDescription;
<commit_msg>this small change should be enough for #237<commit_after>import React, { Component } from 'react';
import { Actions } from 'react-native-router-flux';
import { View, TouchableOpacity, Linking } from 'react-native';
import { Text, Left, Right, Body, CardItem, Label, Icon, Thumbnail } from 'native-base';
import { parseString } from 'react-native-xml2js';
import ParsedText from './ParsedText';
import styles from '../styles';

class FeedDescription extends Component {
  redirect(item, options, scene = 'itemDetail') {
      let type;
      if (item.poll) {
          type = 'poll';
      } else if (item.post) {
          type = 'post';
      } else if (item.user_petition) {
          type = 'user-petition';
      }
      Actions[scene]({ entityType: type, entityId: item.entity.id, ...options });
  }

    _renderTitle (item) {
        if (item.title) {
            return (<Text style={styles.title}>{item.title}</Text>);
        } else {
            return null;
        }
  }
  // The priority zone counter lists the count of total priority zone items in the newsfeed
  _renderZoneIcon(item) {
    if (item.zone === 'prioritized') {
      return (<Icon active name='ios-flash' style={styles.zoneIcon} />);
    } else {
      return null;
    }
  }

  _renderAttachedImage(item){
    // console.log(item);
    let imgURL;
    let blur;
    if (item.post){
        imgURL = item.post.image;
    } else if (item.user_petition) {
        imgURL = item.user_petition.image;
    }
    if (!imgURL) return null;

    if (item.user.follow_status === 'active'){
      blur = '0';
    } else if (item.user.id !== this.props.profile.id){
      blur = '1000';
    }
    return (
      <View style={{width: 80, marginRight: 0, justifyContent: 'flex-end', alignItems: 'center', alignSelf: 'flex-end'}} >
        <Thumbnail medium square
            source={{uri: imgURL +`&w=400&h=400&blur=${blur}&auto=compress,format,q=95`}}
            />
      </View>);
    }
  

  handleUrlPress = url => {
    Linking.openURL(url);
  }

  handleUserPress = user => {
    try {
      const html = this.props.item.description_html;
      parseString(`<body>${html}</body>`, function (err, result) {
          result.body.a.forEach(value => {
            if (value._ === user) {
              Actions.profile({ id: value.$['data-user-id'] });
              return;
            }
          })
      });
    } catch(err) {

    }
  }

  handleHashtagPress = hashtag => {
    Actions.search({ search: hashtag.substring(1), initialPage: 2 });
  }

  render() {
    let { item } = this.props;

    return (
      <CardItem style={{ paddingLeft: 15, paddingRight: 15 }}>
        <Left>
          <View style={styles.descLeftContainer}>
            {this._renderZoneIcon(item)}
            <Label style={styles.commentCount}>{item.responses_count}</Label>
          </View>
          <Body style={styles.descBodyContainer}>
            <TouchableOpacity onPress={() => this.redirect(item)}>
              {this._renderTitle(item)}
              <ParsedText
                style={styles.description}
                parse={
                  [
                    { type: 'url', style: styles.url, onPress: this.handleUrlPress },
                    { pattern: /@(\w+)/, style: styles.username, onPress: this.handleUserPress },
                    { pattern: /#(\w+)/, style: styles.hashtag, onPress: this.handleHashtagPress },
                  ]
                }
                numberOfLines={5}
                childrenProps={{ allowFontScaling: false }}
              >
                {item.description}
              </ParsedText>
            </TouchableOpacity>
          </Body>
            {this._renderAttachedImage(item)}
        </Left>
      </CardItem>
    );
  }
}
export default FeedDescription;

{'fraction_non_alphanumeric': 0.14610303830911492, 'fraction_numerical': 0.006737120211360634, 'mean_word_length': 2.0115354017501987, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 59, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '5315683', 'n_tokens_mistral': 2334, 'n_tokens_neox': 2233, 'n_words': 492}