<commit_before>import React from 'react-native';
import {connect} from 'react-redux/native'
import * as serverActions from '../redux/actions/serverActions'
import * as shareActions from '../redux/actions/shareActions'
import {Actions} from '../../node_modules/react-native-router-flux'
import FriendList from '../components/FriendList'
import ShareHeader from '../components/ShareHeader'
import ProgressView from '../components/ProgressView'
import {Icon} from '../../node_modules/react-native-icons'
import style, { COLOR_1, COLOR_3 } from '../stylesheets/styles'

let {
  Component,
  StyleSheet,
  View,
  Text,
  TouchableOpacity,
  Dimensions,
  NativeAppEventEmitter,
  NativeModules,
  Platform,
  ProgressBarAndroid,
} = React

let deviceHeight = Dimensions.get('window').height

// credit: brentvatne from his example in
// https://github.com/brentvatne/react-native-linear-gradient
function incrementColor(color, step){
  let colorToInt = parseInt(color.substr(1), 16)
  let nstep = parseInt(step)
  if (!isNaN(colorToInt) && !isNaN(nstep)) {
    colorToInt += nstep
    let ncolor = colorToInt.toString(16)
    ncolor = '#' + (new Array(7-ncolor.length).join(0)) + ncolor
    if (/^#[0-9a-f]{6}$/i.test(ncolor)) {
      return ncolor
    }
  }
  return color;
}

class ShareContainer extends Component {

  constructor(props) {
    super(props)
    this.state = {bgColor:'cc22aa'}
  }

  componentDidMount() {
    const {resetSelectedFriends, shareFormChanged, url, title} = this.props
    if (Platform.OS === 'ios') {
      this.subscribeToDataUpdateEvents()
    } else if (this.props.friends) {
      resetSelectedFriends(this.props.friends)
    }
    // We receive title and url from the share extension intially, but ultimately want child compeonnts to
    // react to changes in the redux store so when friend cells are tapped the title/url/comment fields don't
    // get overwritten by old data in these initial props.
    // TOFIX: make this a different action such as "LOAD FROM NATIVE SHARE MODULE"
    shareFormChanged('url', url)
    shareFormChanged('title', title)
  }

  shouldComponentUpdate() {
    console.log('sharecontainer: shouldComponentUpdate')
    return true
  }

  componentWillUnmount() {
    if (Platform.os === 'android') {
      this.friendsListUpdateSubscription.remove();
      this.currentUserUpdateSubscription.remove();
    }
  }

  // update state with the JSON that we'll get through iOS from the native share extension grabbing it out of
  // the special private container that is provided for the extension to communicate with the app...weird shit
  subscribeToDataUpdateEvents() {
    const {friendsSuccess, loginSuccess, resetSelectedFriends} = this.props<commit_msg>don't re-render sharecontainer unless selected friends or sharing state changes<commit_after>import React from 'react-native';
import {connect} from 'react-redux/native'
import * as serverActions from '../redux/actions/serverActions'
import * as shareActions from '../redux/actions/shareActions'
import {Actions} from '../../node_modules/react-native-router-flux'
import FriendList from '../components/FriendList'
import ShareHeader from '../components/ShareHeader'
import ProgressView from '../components/ProgressView'
import {Icon} from '../../node_modules/react-native-icons'
import style, { COLOR_1, COLOR_3 } from '../stylesheets/styles'

let {
  Component,
  StyleSheet,
  View,
  Text,
  TouchableOpacity,
  Dimensions,
  NativeAppEventEmitter,
  NativeModules,
  Platform,
  ProgressBarAndroid,
} = React

let deviceHeight = Dimensions.get('window').height

// credit: brentvatne from his example in
// https://github.com/brentvatne/react-native-linear-gradient
function incrementColor(color, step){
  let colorToInt = parseInt(color.substr(1), 16)
  let nstep = parseInt(step)
  if (!isNaN(colorToInt) && !isNaN(nstep)) {
    colorToInt += nstep
    let ncolor = colorToInt.toString(16)
    ncolor = '#' + (new Array(7-ncolor.length).join(0)) + ncolor
    if (/^#[0-9a-f]{6}$/i.test(ncolor)) {
      return ncolor
    }
  }
  return color;
}

class ShareContainer extends Component {

  constructor(props) {
    super(props)
    this.state = {bgColor:'cc22aa'}
  }

  componentDidMount() {
    const {resetSelectedFriends, shareFormChanged, url, title} = this.props
    if (Platform.OS === 'ios') {
      this.subscribeToDataUpdateEvents()
    } else if (this.props.friends) {
      resetSelectedFriends(this.props.friends)
    }
    // We receive title and url from the share extension intially, but ultimately want child compeonnts to
    // react to changes in the redux store so when friend cells are tapped the title/url/comment fields don't
    // get overwritten by old data in these initial props.
    // TOFIX: make this a different action such as "LOAD FROM NATIVE SHARE MODULE"
    shareFormChanged('url', url)
    shareFormChanged('title', title)
  }


  shouldComponentUpdate(nextProps) {
    let val = nextProps.share.sharing != this.props.share.sharing ||
      nextProps.share.selectedFriends != this.props.share.selectedFriends
    return val
  }

  componentWillUnmount() {
    if (Platform.os === 'android') {
      this.friendsListUpdateSubscription.remove();
      this.currentUserUpdateSubscription.remove();
    }
  }

  // update state with the JSON that we'll get through iOS from the native share extension grabbing it out of
  // the special private container that is provided for the extension to communicate with the app...weird shit
  subscribeToDataUpdateEvents() {
    const {friendsSuccess, loginSuccess, resetSelectedFriends} = this.props
{'fraction_non_alphanumeric': 0.11301553294054634, 'fraction_numerical': 0.004999107302267452, 'mean_word_length': 3.833477135461605, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '1057949', 'n_tokens_mistral': 1654, 'n_tokens_neox': 1623, 'n_words': 468}