function addInvite(inviteData){
    console.log("Adding " + inviteData.uid);
    console.log(friendArr);

    var friendFriendArr;
    if(inviteData.friends == undefined || inviteData.friends == null) {
      friendFriendArr = [];
    } else {
      friendFriendArr = inviteData.friends;
    }

    friendFriendArr.push(user.uid);
    firebase.database().ref("users/" + inviteData.uid).update({
      friends: friendFriendArr
    });


    if (friendArr == undefined || friendArr == null || friendArr.length == 0){
      friendArr = [];
      friendArr.push(inviteData.uid);
      user.friends = [];
      user.friends.push(inviteData.uid);
    } else {
      friendArr.push(inviteData.uid);
      user.friends.push(inviteData.uid);
    }
    firebase.database().ref("users/" + user.uid).update({
      friends: friendArr
    });

    console.log(friendArr);

    deleteInvite(inviteData.uid);
  }
//both data sets to the database.
both data sets to the database.
both data sets to the database .
function addInvite(inviteData){
    console.log("Adding " + inviteData.uid);
    console.log(friendArr);
    var friendFriendArr;
    if(inviteData.friends == undefined || inviteData.friends == null) {
      friendFriendArr = [];
    } else {
      friendFriendArr = inviteData.friends;
    }
    friendFriendArr.push(user.uid);
    firebase.database().ref("users/" + inviteData.uid).update({
      friends: friendFriendArr
    });
    if (friendArr == undefined || friendArr == null || friendArr.length == 0){
      friendArr = [];
      friendArr.push(inviteData.uid);
      user.friends = [];
      user.friends.push(inviteData.uid);
    } else {
      friendArr.push(inviteData.uid);
      user.friends.push(inviteData.uid);
    }
    firebase.database().ref("users/" + user.uid).update({
      friends: friendArr
    });
    console.log(friendArr);
    deleteInvite(inviteData.uid);
  }
function addInvite ( inviteData ) { console . log ( "Adding " + inviteData . uid ) ; console . log ( friendArr ) ; var friendFriendArr ; if ( inviteData . friends == undefined || inviteData . friends == null ) { friendFriendArr = [ ] ; } else { friendFriendArr = inviteData . friends ; } friendFriendArr . push ( user . uid ) ; firebase . database ( ) . ref ( "users/" + inviteData . uid ) . update ( { friends : friendFriendArr } ) ; if ( friendArr == undefined || friendArr == null || friendArr . length == 0 ) { friendArr = [ ] ; friendArr . push ( inviteData . uid ) ; user . friends = [ ] ; user . friends . push ( inviteData . uid ) ; } else { friendArr . push ( inviteData . uid ) ; user . friends . push ( inviteData . uid ) ; } firebase . database ( ) . ref ( "users/" + user . uid ) . update ( { friends : friendArr } ) ; console . log ( friendArr ) ; deleteInvite ( inviteData . uid ) ; }
both data sets to the database.
both data sets to the database .