<commit_before>import React, { Component } from 'react'
import {
  Content, View,
  Left, Body, Right,
  List, ListItem,
  Text, Button, Icon
} from 'native-base'
import {Avatar} from 'react-native-material-ui'

const ROLE_FETCHER = 'Fetcher'
const ROLE_REQUESTER = 'Requester'

const fakeTasks = [
  { content: 'What product would you like?', userID: 1, userAlias: 'Yihao', role: ROLE_REQUESTER, objective: 'Uniqlo Flannel' },
  { content: 'Where are you now?',           userID: 2, userAlias: 'Epan',  role: ROLE_FETCHER,   objective: 'Pencil' }
]

export default class ChatList extends Component {
  state = {
    tasks: fakeTasks
  }
  render = () => (
    <Content>
      <List dataArray={this.state.tasks} renderRow={task => (
        <ListItem onPress={() => this.props.navigation.navigate('ChatRoom', { receiver: { userID: task.userID, userAlias: task.userAlias, role: task.role }, objective: task.objective })} >
            <View style={{width: 70, alignItems: 'center', justifyContent: 'center'}}>
              <Avatar text={task.userAlias[0]} size={40} />
            </View>
            <View style={{ flexDirection: 'column' }}>
              <Text>{task.userAlias} ({task.role})</Text>
              <Text note>{task.objective}</Text>
              <Text note>{task.content}</Text>
            </View>
            <Right>
              <Button iconRight transparent onPress={() => this.props.navigation.navigate('ChatRoom', { receiver: { userID: task.userID, userAlias: task.userAlias, role: task.role }, objective: task.objective })} >
                <Icon name="arrow-forward" />
              </Button>
            </Right>
        </ListItem>
      )} />
    </Content>
  )
}<commit_msg>receive and pass in socket from home<commit_after>import React, { Component } from 'react'
import {
  Content, View,
  Left, Body, Right,
  List, ListItem,
  Text, Button, Icon
} from 'native-base'
import {Avatar} from 'react-native-material-ui'

const ROLE_FETCHER = 'Fetcher'
const ROLE_REQUESTER = 'Requester'

const fakeChats = [
  { content: 'What product would you like?', chatID: 'abc', userID: 1, userAlias: 'Yihao', role: ROLE_REQUESTER, objective: 'Uniqlo Flannel' },
  { content: 'Where are you now?',           chatID: 'xyz', userID: 2, userAlias: 'Epan',  role: ROLE_FETCHER,   objective: 'Pencil' }
]

export default class ChatList extends Component {
  state = {
    chats: fakeChats
  }
  constructor (props) {
    super(props)
    this.socket = this.props.socket
  }
  componentDidMount () {
    for (let chat of this.state.chats) {
      this.socket.emit('join room', chat.chatID, function () {
        this.socket.on('message history', history => {
          console.log('history: ', history)
        })
      }).bind(this)
      this.socket.on('receive message', ({chatID, content}) => {
        console.log('received message from ' + chatID + ': ' + content)
      })
    }
  }
  render = () => {
    let {socket} = this.props
    return (
    <Content>
      <List dataArray={this.state.chats} renderRow={chat => (
        <ListItem onPress={() => this.props.navigation.navigate('ChatRoom', { socket: this.socket, receiver: { userID: chat.userID, userAlias: chat.userAlias, role: chat.role }, objective: chat.objective, chatID: chat.chatID })} >
            <View style={{width: 70, alignItems: 'center', justifyContent: 'center'}}>
              <Avatar text={chat.userAlias[0]} size={40} />
            </View>
            <View style={{ flexDirection: 'column' }}>
              <Text>{chat.userAlias} ({chat.role})</Text>
              <Text note>{chat.objective}</Text>
              <Text note>{chat.content}</Text>
            </View>
            <Right>
              <Button iconRight transparent onPress={() => this.props.navigation.navigate('ChatRoom', { receiver: { userID: chat.userID, userAlias: chat.userAlias, role: chat.role }, objective: chat.objective })} >
                <Icon name="arrow-forward" />
              </Button>
            </Right>
        </ListItem>
      )} />
    </Content>
  )}
}
{'fraction_non_alphanumeric': 0.15576400888669464, 'fraction_numerical': 0.003455936805726981, 'mean_word_length': 2.7174311926605506, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 55, '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': '7353336', 'n_tokens_mistral': 1267, 'n_tokens_neox': 1253, 'n_words': 302}