<commit_before>import React from 'react'
import {
  ScrollView,
  StyleSheet,
  Text,
  Image,
  View,
  TouchableHighlight,
  SegmentedControlIOS,
  RefreshControl,
  ActionSheetIOS,
  Linking,
  SectionList,
  FlatList
} from 'react-native'
import { Icon, Divider, ListItem, List } from 'react-native-elements'
import Accordion from 'react-native-collapsible/Accordion'

import LoadingComponent from './../../components/LoadingComponent'
import ErrorComponent from './../../components/ErrorComponent'

import { CategorieList } from './../../components/novel'

iconHeart = ['md-heart-outline', 'md-heart']

export default class NovelDetailScreen extends React.PureComponent {
  static navigationOptions = ({ navigation }) => ({
    title: `${navigation.state.params.title}`,
    headerRight: (
      <Icon
        type="ionicon"
        name="ios-more"
        style={{ marginRight: 15 }}
        underlayColor="#EFEFF2"
        size={36}
        onPress={navigation.state.params.more}
      />
    )
  })

  constructor(props) {
    super(props)
    this.getData = this.getData.bind(this)
  }

  state = {
    favorite: false,
    novel: {},
    isFetching: true,
    refreshing: false,
    error: undefined,
    image: {},
    iconHeart: iconHeart[0],
    segmentIndex: 'Information',
    selectedIndex: 0,
    oneShot: false,
    volumeNumber: 0
  }

  componentDidMount() {
    this.props.navigation.setParams({ more: this.more })
  }

  more = () => {
    let str = this.state.favorite ? 'Remove From Favorite' : 'Add To Favorite'
    ActionSheetIOS.showActionSheetWithOptions(
      {
        options: [str, 'Open In Safari', 'Cancel'],
        cancelButtonIndex: 2
      },
      index => {
        if (index === 0) {
          this._onHeartPress()
        }
        if (index === 1) {
          const { page } = this.props.navigation.state.params
          Linking.openURL(
            `https://www.baka-tsuki.org/project/index.php?title=${page}`
          )
        }
      }
    )
  }

  async componentWillMount() {
    try {
      await this.getData()
    } catch (e) {
      this.setState(prevState => {
        return { ...prevState, error: e.message, isFetching: false }
      })
    }
  }

  async getData() {
    this.setState(prevState => ({ ...prevState, refreshing: true }))
    const { page } = this.props.navigation.state.params

    const fetched = await fetch(
      `https://btapi.herokuapp.com/api?title=${encodeURIComponent(page)}`
    )
    const json = await fetched.json()

    const correctCat = json.categories.map(el => {
      if (el.toLowerCase().includes('genre')) return el.replace('Genre -', '')
    })
    const filteredCat = correctCat.filter(el => typeof el === 'string')

    json.categories = filteredCat
    let oneShot = json.series[0].books[0].page !== undefined ? true : false
    alert(oneShot)<commit_msg>fix for one_off & new API<commit_after>import React from 'react'
import {
  ScrollView,
  StyleSheet,
  Text,
  Image,
  View,
  TouchableHighlight,
  SegmentedControlIOS,
  RefreshControl,
  ActionSheetIOS,
  Linking,
  SectionList,
  FlatList
} from 'react-native'
import { Icon, Divider, ListItem, List } from 'react-native-elements'
import Accordion from 'react-native-collapsible/Accordion'

import LoadingComponent from './../../components/LoadingComponent'
import ErrorComponent from './../../components/ErrorComponent'

import { CategorieList } from './../../components/novel'

iconHeart = ['md-heart-outline', 'md-heart']

export default class NovelDetailScreen extends React.PureComponent {
  static navigationOptions = ({ navigation }) => ({
    title: `${navigation.state.params.title}`,
    headerRight: (
      <Icon
        type="ionicon"
        name="ios-more"
        style={{ marginRight: 15 }}
        underlayColor="#EFEFF2"
        size={36}
        onPress={navigation.state.params.more}
      />
    )
  })

  constructor(props) {
    super(props)
    this.getData = this.getData.bind(this)
  }

  state = {
    favorite: false,
    novel: {},
    isFetching: true,
    refreshing: false,
    error: undefined,
    image: {},
    iconHeart: iconHeart[0],
    segmentIndex: 'Information',
    selectedIndex: 0,
    oneShot: false,
    volumeNumber: 0
  }

  componentDidMount() {
    this.props.navigation.setParams({ more: this.more })
  }

  more = () => {
    let str = this.state.favorite ? 'Remove From Favorite' : 'Add To Favorite'
    ActionSheetIOS.showActionSheetWithOptions(
      {
        options: [str, 'Open In Safari', 'Cancel'],
        cancelButtonIndex: 2
      },
      index => {
        if (index === 0) {
          this._onHeartPress()
        }
        if (index === 1) {
          const { page } = this.props.navigation.state.params
          Linking.openURL(
            `https://www.baka-tsuki.org/project/index.php?title=${page}`
          )
        }
      }
    )
  }

  async componentWillMount() {
    try {
      await this.getData()
    } catch (e) {
      this.setState(prevState => {
        return { ...prevState, error: e.message, isFetching: false }
      })
    }
  }

  async getData() {
    this.setState(prevState => ({ ...prevState, refreshing: true }))
    const { page } = this.props.navigation.state.params

    const fetched = await fetch(
      `https://btapi.herokuapp.com/api?title=${encodeURIComponent(page)}`
    )
    const json = await fetched.json()

    const correctCat = json.categories.map(el => {
      if (el.toLowerCase().includes('genre')) return el.replace('Genre -', '')
    })
    const filteredCat = correctCat.filter(el => typeof el === 'string')

    json.categories = filteredCat
    let oneShot = json.one_off

{'fraction_non_alphanumeric': 0.14101431348294752, 'fraction_numerical': 0.00424103198444955, 'mean_word_length': 2.600508905852417, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, 'https://': 4, 'lorem ipsum': 0, 'www.': 2, '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': '4543799', 'n_tokens_mistral': 1785, 'n_tokens_neox': 1761, 'n_words': 361}