<commit_before>import findIndex from 'array-findindex';
import React from 'react';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';

import { openLoginModal, openRegisterModal } from '../../actions/LoginActionCreators';
import { togglePlaylistManager } from '../../actions/OverlayActionCreators';
import { joinWaitlist, leaveWaitlist } from '../../actions/WaitlistActionCreators';

import FooterBar from './';

function getRemaining(current, currentTime, startTime) {
  const duration = current.end - current.start; // seconds
  const elapsed = (currentTime - startTime) / 1000; // ms → seconds
  return duration - elapsed;
}

function getEta(current, currentTime, startTime, waitlist, user) {
  const averagePlayDuration = 4 * 60;
  let position = user ? findIndex(waitlist, waiting => waiting._id === user._id) : -1;
  if (position === -1) {
    position = waitlist.length;
  }
  return position * averagePlayDuration + (current ? getRemaining(current, currentTime, startTime) : 0);
}

function mapStateToProps({ auth, booth, playlists, time, waitlist }) {
  return {
    eta: booth.media && auth.user
      ? getEta(booth.media, time, booth.startTime, waitlist.waitlist, auth.user)
      : 0,
    playlist: playlists.playlists[playlists.activePlaylistID],
    nextMedia: playlists.activeMedia[0],
    user: auth.user,
    userInWaitlist: waitlist.waitlist.some(wl => wl._id === auth.user._id)
  };
}

function mapDispatchToProps(dispatch) {
  return bindActionCreators({
    joinWaitlist, leaveWaitlist,
    openLoginModal, openRegisterModal,
    togglePlaylistManager
  }, dispatch);
}

@connect(mapStateToProps, mapDispatchToProps)
export default class FooterBarContainer extends React.Component {
  render() {
    return <FooterBar {...this.props} />;
  }
}
<commit_msg>waitlist: fix userInWaitlist check, fixes #70<commit_after>import findIndex from 'array-findindex';
import React from 'react';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';

import { openLoginModal, openRegisterModal } from '../../actions/LoginActionCreators';
import { togglePlaylistManager } from '../../actions/OverlayActionCreators';
import { joinWaitlist, leaveWaitlist } from '../../actions/WaitlistActionCreators';

import FooterBar from './';

function getRemaining(current, currentTime, startTime) {
  const duration = current.end - current.start; // seconds
  const elapsed = (currentTime - startTime) / 1000; // ms → seconds
  return duration - elapsed;
}

function getEta(current, currentTime, startTime, waitlist, user) {
  const averagePlayDuration = 4 * 60;
  let position = user ? findIndex(waitlist, wlId => wlId === user._id) : -1;
  if (position === -1) {
    position = waitlist.length;
  }
  return position * averagePlayDuration + (current ? getRemaining(current, currentTime, startTime) : 0);
}

function mapStateToProps({ auth, booth, playlists, time, waitlist }) {
  const user = auth.user;
  return {
    eta: booth.media && auth.user
      ? getEta(booth.media, time, booth.startTime, waitlist.waitlist, user)
      : 0,
    playlist: playlists.playlists[playlists.activePlaylistID],
    nextMedia: playlists.activeMedia[0],
    user,
    userInWaitlist: user
      ? waitlist.waitlist.some(wlId => wlId === user._id) ||
        !!booth.djID && booth.djID === user._id
      : false
  };
}

function mapDispatchToProps(dispatch) {
  return bindActionCreators({
    joinWaitlist, leaveWaitlist,
    openLoginModal, openRegisterModal,
    togglePlaylistManager
  }, dispatch);
}

@connect(mapStateToProps, mapDispatchToProps)
export default class FooterBarContainer extends React.Component {
  render() {
    return <FooterBar {...this.props} />;
  }
}

{'fraction_non_alphanumeric': 0.12671140939597317, 'fraction_numerical': 0.00697986577181208, 'mean_word_length': 4.218487394957983, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '3853461', 'n_tokens_mistral': 1142, 'n_tokens_neox': 1121, 'n_words': 278}