<commit_before>import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { AngularFireAuth } from 'angularfire2/auth';
import * as firebase from 'firebase/app';
import { AngularFirestoreDocument, AngularFirestore, AngularFirestoreCollection } from "angularfire2/firestore";
import { Component } from '@angular/core';
import { user } from './models/user.model';
import { Router } from "@angular/router";
import { CalendarEvent } from "angular-calendar";



@Injectable()
export class Firebase {
  public auth;
  private _profile;
  private username: string;
  private phone: string;
  private contactname: string;
  private contactphone: string;
  private image: ImageData;
  private contactl: string;
  public userRef;
  private _email: string;
  private contactsRef: AngularFirestoreCollection<any>;

  constructor(public afAuth: AngularFireAuth, private afsDocument: AngularFirestore, public router: Router) {
    this.contactsRef = this.afsDocument.collection("contacts");
    firebase.auth().languageCode = "en";
  }
  async login() {
    let u = await this.afAuth.auth.signInWithPopup(new firebase.auth.GoogleAuthProvider())
    console.log(u);
    //return this.getUserData(u.user.email);
  }

  private getUserData(username: string) { //פעם אחת נקרא לפונקציה היא מאזינה לכל הנתונים של המשתמש
    return new Promise((res, rej) => {
      this.afsDocument.doc("users/" + username).valueChanges().subscribe(user => {
        this._profile = user;
        res(this._profile);
      });
    });

  }
  public updateUser(user)//מעדכנת את הנתונים בשרת
  {
    this.userRef = this.afsDocument.doc("users/" + user.username + user.phone + user.contactId+this.contactsRef);
    this.userRef.set(user);
    // this.router.navigate(["home"]);
  }
  public updateContact(contact){//מעדכנת את איש הקשר בשרת
    this.contactsRef = this.afsDocument.collection("contacts/" + contact.contactname + contact.contactphone);
    this.contactsRef.add("contacts/");
  }
  logout() {
    this.afAuth.auth.signOut();
  }

  public getEmail() {
    if (this.afAuth.auth.currentUser)
      this._email = this.afAuth.auth.currentUser.email;
    else
      this._email = "";
    return this._email;
  }
  updateProfile(obj) {
    this._profile = obj;<commit_msg>firebase looking<commit_after>import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { AngularFireAuth } from 'angularfire2/auth';
import * as firebase from 'firebase/app';
import { AngularFirestoreDocument, AngularFirestore, AngularFirestoreCollection } from "angularfire2/firestore";
import { Component } from '@angular/core';
import { user } from './models/user.model';
import { Router } from "@angular/router";
import { CalendarEvent } from "angular-calendar";



@Injectable()
export class Firebase {
  public auth;
  private _profile;
  private username: string;
  private phone: string;
  private contactname: string;
  private contactphone: string;
  private image: ImageData;
  private contactl: string;
  public userRef;
  private _email: string;
  private contactsRef: AngularFirestoreCollection<any>;

  constructor(public afAuth: AngularFireAuth, private afsDocument: AngularFirestore, public router: Router) {
    this.contactsRef = this.afsDocument.collection("contacts");
    firebase.auth().languageCode = "en";
  }
  async login() {
    let u = await this.afAuth.auth.signInWithPopup(new firebase.auth.GoogleAuthProvider())
    console.log(u);
    //return this.getUserData(u.user.email);
  }

  private getUserData(username: string) { //פעם אחת נקרא לפונקציה היא מאזינה לכל הנתונים של המשתמש
    return new Promise((res, rej) => {
      this.afsDocument.doc("users/" + username).valueChanges().subscribe(user => {
        this._profile = user;
        res(this._profile);
      });
    });

  }
  public updateUser(user)//מעדכנת את הנתונים בשרת
  {
    this.userRef = this.afsDocument.doc("users/" + user.username);
    this.userRef.set(user);
    // this.router.navigate(["home"]);
  }
  public updateContact(contact){//מעדכנת את איש הקשר בשרת
    this.contactsRef = this.afsDocument.collection("contacts/" + contact.contactname + contact.contactphone);
    this.contactsRef.add("contacts/");
  }
  logout() {
    this.afAuth.auth.signOut();
  }

  public getEmail() {
    if (this.afAuth.auth.currentUser)
      this._email = this.afAuth.auth.currentUser.email;
    else
      this._email = "";
    return this._email;
  }
  updateProfile(obj) {
    this._profile = obj;
{'fraction_non_alphanumeric': 0.12771618625277162, 'fraction_numerical': 0.0008869179600886918, 'mean_word_length': 3.9625962596259625, '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': '6931109', 'n_tokens_mistral': 1530, 'n_tokens_neox': 1474, 'n_words': 310}