<commit_before>// @flow
import React from 'react'
import {StyleSheet, Platform, Share} from 'react-native'
import * as c from '../components/colors'
import SimpleListView from '../components/listview'
import type {StoryType} from './types'
import {ListSeparator} from '../components/list'
import {NoticeView} from '../components/notice'
import type {TopLevelViewPropsType} from '../types'
import {NewsRow} from './news-row'
import Icon from 'react-native-vector-icons/Ionicons'
import {Touchable} from '../components/touchable'

const styles = StyleSheet.create({
  listContainer: {
    backgroundColor: c.white,
  },
})

type NewsListPropsType = TopLevelViewPropsType & {
  name: string,
  onRefresh: () => any,
  entries: StoryType[],
  loading: boolean,
  embedFeaturedImage: ?boolean,
};

export class NewsList extends React.Component {
  props: NewsListPropsType;

  renderSeparator = (sectionId: string, rowId: string) => {
    return <ListSeparator key={`${sectionId}-${rowId}`} />
  };

  shareItem = (story: StoryType) => {
    Share.share({
      url: story.link,
      message: story.link,
    })
      .then(result => console.log(result))
      .catch(error => console.log(error.message))
  };

  onPressNews = (title: string, story: StoryType) => {
    this.props.navigator.push({
      id: 'NewsItemView',
      index: this.props.route.index + 1,
      title: title,
      backButtonTitle: this.props.name,
      props: {story, embedFeaturedImage: this.props.embedFeaturedImage},
      rightButton: ({contentContainerStyle, style}) => (
        <Touchable
          highlight={false}
          style={[contentContainerStyle]}
          onPress={() => this.shareItem(story)}
        >
          {Platform.OS === 'ios'
            ? <Icon style={[style]} name="ios-share-outline" />
            : <Icon style={[style]} name="md-share" />}
        </Touchable>
      ),
    })
  };

  render() {
    // remove all entries with a <form> from the list
    const entries = this.props.entries.filter(
      entry => !entry.content.includes('<form>'),
    )

    if (!entries.length) {
      return <NoticeView text="No news." />
    }

    return (
      <SimpleListView
        style={styles.listContainer}
        forceBottomInset={true}
        data={entries}<commit_msg>Remove forms and blank news stories (#865)<commit_after>// @flow
import React from 'react'
import {StyleSheet, Platform, Share} from 'react-native'
import * as c from '../components/colors'
import SimpleListView from '../components/listview'
import type {StoryType} from './types'
import {ListSeparator} from '../components/list'
import {NoticeView} from '../components/notice'
import type {TopLevelViewPropsType} from '../types'
import {NewsRow} from './news-row'
import Icon from 'react-native-vector-icons/Ionicons'
import {Touchable} from '../components/touchable'

const styles = StyleSheet.create({
  listContainer: {
    backgroundColor: c.white,
  },
})

type NewsListPropsType = TopLevelViewPropsType & {
  name: string,
  onRefresh: () => any,
  entries: StoryType[],
  loading: boolean,
  embedFeaturedImage: ?boolean,
};

export class NewsList extends React.Component {
  props: NewsListPropsType;

  renderSeparator = (sectionId: string, rowId: string) => {
    return <ListSeparator key={`${sectionId}-${rowId}`} />
  };

  shareItem = (story: StoryType) => {
    Share.share({
      url: story.link,
      message: story.link,
    })
      .then(result => console.log(result))
      .catch(error => console.log(error.message))
  };

  onPressNews = (title: string, story: StoryType) => {
    this.props.navigator.push({
      id: 'NewsItemView',
      index: this.props.route.index + 1,
      title: title,
      backButtonTitle: this.props.name,
      props: {story, embedFeaturedImage: this.props.embedFeaturedImage},
      rightButton: ({contentContainerStyle, style}) => (
        <Touchable
          highlight={false}
          style={[contentContainerStyle]}
          onPress={() => this.shareItem(story)}
        >
          {Platform.OS === 'ios'
            ? <Icon style={[style]} name="ios-share-outline" />
            : <Icon style={[style]} name="md-share" />}
        </Touchable>
      ),
    })
  };

  render() {
    // remove all entries with blank excerpts
    // remove all entries with a <form from the list
    const entries = this.props.entries
      .filter(entry => entry.excerpt.trim() !== '')
      .filter(entry => !entry.content.includes('<form'))

    if (!entries.length) {
      return <NoticeView text="No news." />
    }

    return (
      <SimpleListView
        style={styles.listContainer}
        forceBottomInset={true}
        data={entries}
{'fraction_non_alphanumeric': 0.1491134372997223, 'fraction_numerical': 0.0010681478316599017, 'mean_word_length': 3.0257953568357694, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 36, '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': '2861689', 'n_tokens_mistral': 1401, 'n_tokens_neox': 1382, 'n_words': 331}