<commit_before>import firebase from 'firebase/app';
import 'firebase/auth';
import 'firebase/firestore';
import * as firebaseui from 'firebaseui';
import User from './User';

var firebaseConfig = {
    apiKey: process.env.REACT_APP_API_KEY,
    authDomain:  process.env.REACT_APP_AUTH_DOMAIN,
    databaseURL: process.env.REACT_APP_DATABASE_URL,
    projectId: process.env.REACT_APP_PROJECT_ID,
    storageBucket: process.env.REACT_APP_STORAGE_BUCKET,
    messagingSenderId: process.env.REACT_APP_MESSAGING_SENDER_ID,
    appId: "1:390165048626:web:6e692e8fa9d6c5ea1dbb2b",
    measurementId: "G-JPC7PLV9CF",
  };

class Firebase {
  constructor() {
    firebase.initializeApp(firebaseConfig);
    this.db = firebase.firestore();
    this.auth = firebase.auth();
    this.ui = new firebaseui.auth.AuthUI(this.auth);
    this.uiConfig = {
      signInSuccessUrl: 'index.html',
      signInOptions: [
        firebase.auth.GoogleAuthProvider.PROVIDER_ID,
        firebase.auth.FacebookAuthProvider.PROVIDER_ID,
        firebase.auth.EmailAuthProvider.PROVIDER_ID,
      ],
      tosUrl: 'index.html',
      privacyPolicyUrl: function() {
        window.location.assign('index.html');
      }
    };
  }

  getTrips = (email) => {return {"1" : "tripA"}};
  createFirebaseWidget = () => {this.ui.start("#firebaseui-auth-container", this.uiConfig)};
  getUserInfo = () => {
    return new Promise((resolve, reject) => {
      this.auth.onAuthStateChanged((user) => {
        if (user) {
          // User is signed in.
          let trips = this.getTrips(user.email);
          let userObject = new User(user.email, user.displayName, trips);
          resolve({signInStatus: true, user: userObject});

        } else {
          // User is signed out.
          resolve({signInStatus: false, user: null});
        }
      })
        
    });
  }

  getTrip(reference){
    const doc = this.db.doc(reference);
    return doc.get();
  }

  getTripList(reference){
    const collec = this.db.collection(reference);
    return collec.get();
  }

  addTrip(reference, trip) {
    const tripListRef = this.db.collection(reference);
    return tripListRef.add(trip);
  }

  addTravelObject(reference, travelObject) {
    const tripRef = this.db.doc(reference);
    return tripRef.update({travelObjects: firebase.firestore.FieldValue.arrayUnion(travelObject)});
  }

  editTravelObject(reference, oldTravelObject, newTravelObject) {
    const tripRef = this.db.doc(reference); 
    return new Promise((resolve) => {
      tripRef.update({travelObjects : firebase.firestore.FieldValue.arrayRemove(oldTravelObject)})
      .then(() => {
        tripRef.update({travelObjects : firebase.firestore.FieldValue.arrayUnion(newTravelObject)})
        .then(() => {resolve()});
     })
    });
  }

  editTrip(reference, data) {
    //TODO: Implement when details of trip editing and settings are implemented
  }

  deleteTravelObject(reference, travelObject) {
    const tripRef = this.db.doc(reference);
    return tripRef.update({travelObjects : firebase.firestore.FieldValue.arrayRemove(travelObject)});
  }

  deleteTrip(reference) {
    const tripRef = this.db.doc(reference);
    return tripRef.delete()
  }

}
 
export default Firebase;<commit_msg>final fixes to code consistency and commenting out editTrip function<commit_after>import firebase from 'firebase/app';
import 'firebase/auth';
import 'firebase/firestore';
import * as firebaseui from 'firebaseui';
import User from './User';

var firebaseConfig = {
    apiKey: process.env.REACT_APP_API_KEY,
    authDomain:  process.env.REACT_APP_AUTH_DOMAIN,
    databaseURL: process.env.REACT_APP_DATABASE_URL,
    projectId: process.env.REACT_APP_PROJECT_ID,
    storageBucket: process.env.REACT_APP_STORAGE_BUCKET,
    messagingSenderId: process.env.REACT_APP_MESSAGING_SENDER_ID,
    appId: "1:390165048626:web:6e692e8fa9d6c5ea1dbb2b",
    measurementId: "G-JPC7PLV9CF",
  };

class Firebase {
  constructor() {
    firebase.initializeApp(firebaseConfig);
    this.db = firebase.firestore();
    this.auth = firebase.auth();
    this.ui = new firebaseui.auth.AuthUI(this.auth);
    this.uiConfig = {
      signInSuccessUrl: 'index.html',
      signInOptions: [
        firebase.auth.GoogleAuthProvider.PROVIDER_ID,
        firebase.auth.FacebookAuthProvider.PROVIDER_ID,
        firebase.auth.EmailAuthProvider.PROVIDER_ID,
      ],
      tosUrl: 'index.html',
      privacyPolicyUrl: function() {
        window.location.assign('index.html');
      }
    };
  }

  getTrips = (email) => {return {"1" : "tripA"}};
  createFirebaseWidget = () => {this.ui.start("#firebaseui-auth-container", this.uiConfig)};
  getUserInfo = () => {
    return new Promise((resolve, reject) => {
      this.auth.onAuthStateChanged((user) => {
        if (user) {
          // User is signed in.
          let trips = this.getTrips(user.email);
          let userObject = new User(user.email, user.displayName, trips);
          resolve({signInStatus: true, user: userObject});

        } else {
          // User is signed out.
          resolve({signInStatus: false, user: null});
        }
      })
        
    });
  }

  getTrip(reference){
    const tripRef = this.db.doc(reference);
    return tripRef.get();
  }

  getTripList(reference){
    const tripListRef = this.db.collection(reference);
    return tripListRef.get();
  }

  addTrip(reference, trip) {
    const tripListRef = this.db.collection(reference);
    return tripListRef.add(trip);
  }

  addTravelObject(reference, travelObject) {
    const tripRef = this.db.doc(reference);
    return tripRef.update({travelObjects: firebase.firestore.FieldValue.arrayUnion(travelObject)});
  }

  editTravelObject(reference, oldTravelObject, newTravelObject) {
    const tripRef = this.db.doc(reference); 
    return new Promise((resolve) => {
      tripRef.update({travelObjects : firebase.firestore.FieldValue.arrayRemove(oldTravelObject)})
      .then(() => {
        tripRef.update({travelObjects : firebase.firestore.FieldValue.arrayUnion(newTravelObject)})
        .then(() => {resolve()});
     })
    });
  }
// TODO: Implement when details of trip editing and settings are implemented
//   editTrip(reference, data) {
    
//   }

  deleteTravelObject(reference, travelObject) {
    const tripRef = this.db.doc(reference);
    return tripRef.update({travelObjects : firebase.firestore.FieldValue.arrayRemove(travelObject)});
  }

  deleteTrip(reference) {
    const tripRef = this.db.doc(reference);
    return tripRef.delete()
  }

}
 
export default Firebase;
{'fraction_non_alphanumeric': 0.12767257177764202, 'fraction_numerical': 0.00794135613927917, 'mean_word_length': 3.374749498997996, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, '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': '669636', 'n_tokens_mistral': 2161, 'n_tokens_neox': 2088, 'n_words': 354}