function checkUserErrors(){
  var userUIDs = [];
  var inviteEditInt = 0;
  var friendEditInt = 0;
  var totalErrors = 0;

  for(var i = 0; i < userArr.length; i++){
    userUIDs.push(userArr[i].uid);
  }

  console.log("Checking for errors...");

  //check invites for users that no longer exist
  if(invitesValidBool){
    for(var i = 0; i < user.invites.length; i++){
      if(!userUIDs.includes(user.invites[i])){
        user.invites.splice(i, 1);
        inviteEditInt++;
      }
    }

    if(inviteEditInt > 0){
      updateUserBool = true;
      console.log("Update to DB required: 1...");
    }

    if(user.invites.length > 0) {
      inviteNote.style.background = "#ff3923";
    }
  }

  //check friends for users that no longer exist
  if(friendsValidBool){
    for(var i = 0; i < user.friends.length; i++){
      if(!userUIDs.includes(user.friends[i])){
        user.friends.splice(i, 1);
        friendEditInt++;
      }
    }

    if(friendEditInt > 0){
      updateUserBool = true;
      console.log("Update to DB required: 2...");
    }
  }

  if(updateUserBool){
    console.log("Updates needed! Computing...");
    totalErrors = friendEditInt + inviteEditInt;
    updateUserToDB(totalErrors, friendEditInt, inviteEditInt);
  } else {
    console.log("No updates needed!");
  }
}
//friend list. If this is the case, then the user's data will be properly updated in the database.
friend list. If this is the case, then the user's data will be properly updated in the database.
friend list . If this is the case then the user ' s data will be properly updated in the database .
function checkUserErrors(){
  var userUIDs = [];
  var inviteEditInt = 0;
  var friendEditInt = 0;
  var totalErrors = 0;
  for(var i = 0; i < userArr.length; i++){
    userUIDs.push(userArr[i].uid);
  }
  console.log("Checking for errors...");
  if(invitesValidBool){
    for(var i = 0; i < user.invites.length; i++){
      if(!userUIDs.includes(user.invites[i])){
        user.invites.splice(i, 1);
        inviteEditInt++;
      }
    }
    if(inviteEditInt > 0){
      updateUserBool = true;
      console.log("Update to DB required: 1...");
    }
    if(user.invites.length > 0) {
      inviteNote.style.background = "#ff3923";
    }
  }
  if(friendsValidBool){
    for(var i = 0; i < user.friends.length; i++){
      if(!userUIDs.includes(user.friends[i])){
        user.friends.splice(i, 1);
        friendEditInt++;
      }
    }
    if(friendEditInt > 0){
      updateUserBool = true;
      console.log("Update to DB required: 2...");
    }
  }
  if(updateUserBool){
    console.log("Updates needed! Computing...");
    totalErrors = friendEditInt + inviteEditInt;
    updateUserToDB(totalErrors, friendEditInt, inviteEditInt);
  } else {
    console.log("No updates needed!");
  }
}
function checkUserErrors ( ) { var userUIDs = [ ] ; var inviteEditInt = 0 ; var friendEditInt = 0 ; var totalErrors = 0 ; for ( var i = 0 ; i < userArr . length ; i ++ ) { userUIDs . push ( userArr [ i ] . uid ) ; } console . log ( "Checking for errors..." ) ; if ( invitesValidBool ) { for ( var i = 0 ; i < user . invites . length ; i ++ ) { if ( ! userUIDs . includes ( user . invites [ i ] ) ) { user . invites . splice ( i , 1 ) ; inviteEditInt ++ ; } } if ( inviteEditInt > 0 ) { updateUserBool = true ; console . log ( "Update to DB required: 1..." ) ; } if ( user . invites . length > 0 ) { inviteNote . style . background = "#ff3923" ; } } if ( friendsValidBool ) { for ( var i = 0 ; i < user . friends . length ; i ++ ) { if ( ! userUIDs . includes ( user . friends [ i ] ) ) { user . friends . splice ( i , 1 ) ; friendEditInt ++ ; } } if ( friendEditInt > 0 ) { updateUserBool = true ; console . log ( "Update to DB required: 2..." ) ; } } if ( updateUserBool ) { console . log ( "Updates needed! Computing..." ) ; totalErrors = friendEditInt + inviteEditInt ; updateUserToDB ( totalErrors , friendEditInt , inviteEditInt ) ; } else { console . log ( "No updates needed!" ) ; } }
friend list.
friend list .
//check invites for users that no longer exist //check friends for users that no longer exist