<commit_before>import React, { Component } from 'react';

// theme information, imports colors and material-ui information from node modules
import getMuiTheme from 'material-ui/styles/getMuiTheme';
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
import {fade} from 'material-ui/utils/colorManipulator';
import {
  deepPurple900,
  deepPurple500,
  deepPurple100,
  pinkA200,
  lightGreenA400,
  fullWhite
} from 'material-ui/styles/colors';

// list of objects/ views being imported
import Welcome from './Welcome.js';
import UserVoteList from './UserVoteList.js';
import Search from './Search.js';
import SearchResults from './SearchResults.js';
import NavBar from './NavBar.js';
import LoadingUser from './LoadingUser.js';
import DefaultSearch from './DefaultSearch.js';
import PartyButton from './PartyButton.js';

const muiTheme = getMuiTheme({
  fontFamily: 'Roboto, sans-serif',
  palette: {
    primary1Color: deepPurple500,
    primary2Color: pinkA200,
    primary3Color: lightGreenA400,
    accent1Color: deepPurple900,
    accent2Color: deepPurple500,
    accent3Color: deepPurple500,
    textColor: fullWhite,
    alternateTextColor: deepPurple900,
    canvasColor: '#303030',
    borderColor: deepPurple900,
    disabledColor: deepPurple100,
    pickerHeaderColor: deepPurple500,
    clockCircleColor: fade(deepPurple500, 0.07),
    shadowColor: deepPurple500,
  },
});

class Users extends Component {

  componentDidMount() {
    console.log('componentDidMount <App />');
    console.log('Opening socket connection');

    this.props.ws.on('updateUpNext', (upNext) => {
      console.log('upNext', upNext);
      this.setState({ voteListLoaded: true, 'upNext': upNext.data });
      console.log('Current state: ', this.state);
    });

    this.props.ws.on('updatePlaylist', (playlist) => {
      console.log('playlist', playlist);
      let playlistById = [];
      playlist.data.forEach(function(item) {
        playlistById.push(item.songId)
      })
      console.log(playlistById)
      this.setState({ playlist: playlistById });
      console.log('Current state: ', this.state);
    });

    this.props.ws.on('checkForUpNext', (data) => {
      console.log('Received a message from the server!', data);
      if (data.upNext.length > 0) {
        this.setState({ upNext: data.upNext, voteListLoaded: true });
      };
    });
  };

  componentWillUnmount() {
    console.log('Closing socket connection');
    this.props.ws.close();
  };

  constructor(props) {
    super(props);

    this.state = {
      view: 3,
      userCount: 0,
      searchResults: [],
      user: { id: 0, name: '' },
      voteListLoaded: false,
      upNext: [],
      playlist: [],
      selectedSongs: [],
      newVoteId: '',
      readyToParty: true,
    };

    this.renderView = () => {
      switch (this.state.view) {
        case 3:
          return (
            <Welcome handleNewName={this.handleNewName} handleSubmitName={this.handleSubmitName}/>
        )
        case 0:
          if (this.state.voteListLoaded === false) {
            return (
            <div>
              <LoadingUser />
              <NavBar switcher={this.switcher} view={this.state.view}/>
            </div>
          )
        } else if (this.state.readyToParty === true) {
          return (
            <div>
              <PartyButton handlePartyPress={this.handlePartyPress}/>
              <UserVoteList voteFor={this.handleSongClick} upNext={this.state.upNext} newVoteId={this.state.newVoteId}/>
              <NavBar switcher={this.switcher} view={this.state.view}/>
            </div>
          )
        } else {
              return (
                <div>
                  <UserVoteList voteFor={this.handleSongClick} upNext={this.state.upNext} newVoteId={this.state.newVoteId}/>
                  <NavBar switcher={this.switcher} view={this.state.view}/>
                </div>
              )
            }
        case 1:
          if (this.state.searchResults < 1 ){
            return (
            <div>
              <Search updateSearchResultsList={this.updateSearchResultsList} />
              <DefaultSearch />
              <NavBar switcher={this.switcher} view={this.state.view}/>
            </div>
          )
            } else {
              return (
                <div>
                  <Search updateSearchResultsList={this.updateSearchResultsList} switcher={this.switcher} />
                  <SearchResults results={this.state.searchResults} submitNewSong={this.handleSongAddition} selectedSongs={this.state.selectedSongs} playlist={this.state.playlist}/>
                  <NavBar switcher={this.switcher} view={this.state.view}/>
                </div>
              )
            }
        default:
          break;
      };
    };
  };

  switcher = (newView) => {
    this.setState({ view: newView });
  };

  updateSearchResultsList = (results) => {
    this.setState({ searchResults: results});
  };

  handlePartyPress = () => {
    
  };

  handleSubmitName = () => {
    if (this.state.user.name) {
      let name = this.state.user.name;
      console.log('Sending username to server', name);
      this.props.ws.emit('setUsername', { 'name': name }, (userId) => {
        console.log('Received UUID from server', userId);
        this.setState({ user: { id: userId , name: name } });
        console.log('Current state: ', this.state);
      });
        if (this.state.voteListLoaded === true) {<commit_msg>put state of party button to false<commit_after>import React, { Component } from 'react';

// theme information, imports colors and material-ui information from node modules
import getMuiTheme from 'material-ui/styles/getMuiTheme';
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
import {fade} from 'material-ui/utils/colorManipulator';
import {
  deepPurple900,
  deepPurple500,
  deepPurple100,
  pinkA200,
  lightGreenA400,
  fullWhite
} from 'material-ui/styles/colors';

// list of objects/ views being imported
import Welcome from './Welcome.js';
import UserVoteList from './UserVoteList.js';
import Search from './Search.js';
import SearchResults from './SearchResults.js';
import NavBar from './NavBar.js';
import LoadingUser from './LoadingUser.js';
import DefaultSearch from './DefaultSearch.js';
import PartyButton from './PartyButton.js';

const muiTheme = getMuiTheme({
  fontFamily: 'Roboto, sans-serif',
  palette: {
    primary1Color: deepPurple500,
    primary2Color: pinkA200,
    primary3Color: lightGreenA400,
    accent1Color: deepPurple900,
    accent2Color: deepPurple500,
    accent3Color: deepPurple500,
    textColor: fullWhite,
    alternateTextColor: deepPurple900,
    canvasColor: '#303030',
    borderColor: deepPurple900,
    disabledColor: deepPurple100,
    pickerHeaderColor: deepPurple500,
    clockCircleColor: fade(deepPurple500, 0.07),
    shadowColor: deepPurple500,
  },
});

class Users extends Component {

  componentDidMount() {
    console.log('componentDidMount <App />');
    console.log('Opening socket connection');

    this.props.ws.on('updateUpNext', (upNext) => {
      console.log('upNext', upNext);
      this.setState({ voteListLoaded: true, 'upNext': upNext.data });
      console.log('Current state: ', this.state);
    });

    this.props.ws.on('updatePlaylist', (playlist) => {
      console.log('playlist', playlist);
      let playlistById = [];
      playlist.data.forEach(function(item) {
        playlistById.push(item.songId)
      })
      console.log(playlistById)
      this.setState({ playlist: playlistById });
      console.log('Current state: ', this.state);
    });

    this.props.ws.on('checkForUpNext', (data) => {
      console.log('Received a message from the server!', data);
      if (data.upNext.length > 0) {
        this.setState({ upNext: data.upNext, voteListLoaded: true });
      };
    });
  };

  componentWillUnmount() {
    console.log('Closing socket connection');
    this.props.ws.close();
  };

  constructor(props) {
    super(props);

    this.state = {
      view: 3,
      userCount: 0,
      searchResults: [],
      user: { id: 0, name: '' },
      voteListLoaded: false,
      upNext: [],
      playlist: [],
      selectedSongs: [],
      newVoteId: '',
      readyToParty: false,
    };

    this.renderView = () => {
      switch (this.state.view) {
        case 3:
          return (
            <Welcome handleNewName={this.handleNewName} handleSubmitName={this.handleSubmitName}/>
        )
        case 0:
          if (this.state.voteListLoaded === false) {
            return (
            <div>
              <LoadingUser />
              <NavBar switcher={this.switcher} view={this.state.view}/>
            </div>
          )
        } else if (this.state.readyToParty === true) {
          return (
            <div>
              <PartyButton handlePartyPress={this.handlePartyPress}/>
              <UserVoteList voteFor={this.handleSongClick} upNext={this.state.upNext} newVoteId={this.state.newVoteId}/>
              <NavBar switcher={this.switcher} view={this.state.view}/>
            </div>
          )
        } else {
              return (
                <div>
                  <UserVoteList voteFor={this.handleSongClick} upNext={this.state.upNext} newVoteId={this.state.newVoteId}/>
                  <NavBar switcher={this.switcher} view={this.state.view}/>
                </div>
              )
            }
        case 1:
          if (this.state.searchResults < 1 ){
            return (
            <div>
              <Search updateSearchResultsList={this.updateSearchResultsList} />
              <DefaultSearch />
              <NavBar switcher={this.switcher} view={this.state.view}/>
            </div>
          )
            } else {
              return (
                <div>
                  <Search updateSearchResultsList={this.updateSearchResultsList} switcher={this.switcher} />
                  <SearchResults results={this.state.searchResults} submitNewSong={this.handleSongAddition} selectedSongs={this.state.selectedSongs} playlist={this.state.playlist}/>
                  <NavBar switcher={this.switcher} view={this.state.view}/>
                </div>
              )
            }
        default:
          break;
      };
    };
  };

  switcher = (newView) => {
    this.setState({ view: newView });
  };

  updateSearchResultsList = (results) => {
    this.setState({ searchResults: results});
  };

  handlePartyPress = () => {

  };

  handleSubmitName = () => {
    if (this.state.user.name) {
      let name = this.state.user.name;
      console.log('Sending username to server', name);
      this.props.ws.emit('setUsername', { 'name': name }, (userId) => {
        console.log('Received UUID from server', userId);
        this.setState({ user: { id: userId , name: name } });
        console.log('Current state: ', this.state);
      });
        if (this.state.voteListLoaded === true) {
{'fraction_non_alphanumeric': 0.13536719035440264, 'fraction_numerical': 0.01351845085860431, 'mean_word_length': 2.3992548897857806, 'pattern_counts': {'":': 0, '<': 55, '<?xml version=': 0, '>': 73, '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': '3771607', 'n_tokens_mistral': 3404, 'n_tokens_neox': 3224, 'n_words': 628}