<commit_before>'use strict';

var React = require('react');
var ReactDOM = require('react-dom');
var Firebase = require('firebase');
var FirebaseUtil = require('firebase-util');
var ReactFireMixin = require('reactfire');
var ReactIntl = require('react-intl');
var Select = require('react-select');

var Model = require('./model.js');
var FacebookLogin = require('./login.jsx');
var CoffeeOrder = require('./coffeeorder.jsx');
var PendingOrderList = require('./pendingorderlist.jsx');
var PaidOrderList = require('./paidorderlist.jsx');
var CandidateList = require('./candidatelist.jsx');
var UserList = require('./userlist.jsx');
var ChatBox = require('./chatbox.jsx');

var C = require('./constants.js');

Firebase.util.log('MyCoffeeApp starting!');
Firebase.util.logLevel(true);

var MyCoffeeApp = React.createClass({
  mixins: [ReactFireMixin],

  getInitialState: function() {
    return {
      uid: null,
      groupId: null,
      groupList: [],
      groupNameToAdd: ''
    };
  },

  onLogin: function(){
    this.model = Model;
    this.model.init(this.firebaseRef);
    if(this.firebaseRef.getAuth()){
      this.setState({uid: this.firebaseRef.getAuth().uid});
      this.firebaseRef
      .child('users')
      .child(this.firebaseRef.getAuth().uid)
      .once('value', function(snapshot){
        this.model.setGroupId(snapshot.val().groupId);
        this.setState({groupId: snapshot.val().groupId})
      }, this);
      this.bindAsArray(this.firebaseRef.child('userGroups').orderByChild('name'), 'groupList');
    }
    else{
      this.model.setGroupId(null);
      this.setState({uid: null, groupId: null});
    }
  },

  componentWillMount: function() {
    this.firebaseRef = new Firebase(C.BASE_FIREBASE_URL);
    this.onLogin();
  },

  updateUserPaymentCacheFromReceipts: function() {
    this.model.updateUserPaymentCacheFromReceipts();
  },<commit_msg>Fixed another issue with login and groups<commit_after>'use strict';

var React = require('react');
var ReactDOM = require('react-dom');
var Firebase = require('firebase');
var FirebaseUtil = require('firebase-util');
var ReactFireMixin = require('reactfire');
var ReactIntl = require('react-intl');
var Select = require('react-select');

var Model = require('./model.js');
var FacebookLogin = require('./login.jsx');
var CoffeeOrder = require('./coffeeorder.jsx');
var PendingOrderList = require('./pendingorderlist.jsx');
var PaidOrderList = require('./paidorderlist.jsx');
var CandidateList = require('./candidatelist.jsx');
var UserList = require('./userlist.jsx');
var ChatBox = require('./chatbox.jsx');

var C = require('./constants.js');

Firebase.util.log('MyCoffeeApp starting!');
Firebase.util.logLevel(true);

var MyCoffeeApp = React.createClass({
  mixins: [ReactFireMixin],

  getInitialState: function() {
    return {
      uid: null,
      groupId: null,
      groupList: [],
      groupNameToAdd: ''
    };
  },

  onLogin: function(){
    this.model = Model;
    this.model.init(this.firebaseRef);
    if(this.firebaseRef.getAuth()){
      this.setState({uid: this.firebaseRef.getAuth().uid});
      this.firebaseRef
      .child('users')
      .child(this.firebaseRef.getAuth().uid)
      .once('value', function(snapshot){
        this.model.setGroupId(snapshot.val().groupId);
        this.setState({groupId: snapshot.val().groupId})
      }, this);
      if(!this.bound){
        this.bindAsArray(this.firebaseRef.child('userGroups').orderByChild('name'), 'groupList');
        this.bound = true;
      }
    }
    else{
      this.model.setGroupId(null);
      this.setState({uid: null, groupId: null});
    }
  },

  componentWillMount: function() {
    this.firebaseRef = new Firebase(C.BASE_FIREBASE_URL);
    this.bound = false;
    this.onLogin();
  },

  updateUserPaymentCacheFromReceipts: function() {
    this.model.updateUserPaymentCacheFromReceipts();
  },
{'fraction_non_alphanumeric': 0.16589147286821707, 'fraction_numerical': 0.0, 'mean_word_length': 3.9375, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2097454', 'n_tokens_mistral': 1232, 'n_tokens_neox': 1221, 'n_words': 213}