karma test case for url redirecting - karma-runner

Karma test case run through Istanbul.
$scope.processChkBoxes = function(listOptions){
var urlAltered = false;
$scope.myData.data = '{}';
url = URLHolder;
$scope.myData.loadDataFlg = true;
$scope.myData.noDataFlg = false;
if(listOptions[0] == true){
Iif(urlAltered == true){
url = url + "&showSubCust=true";
}else{
url = url + "?showSubCust=true";
urlAltered = true;
}
}
if(listOptions[1] == true){
Eif(urlAltered == true){
url = url + "&showSettled=true";
}else{
url = url + "?showSettled=true";
urlAltered = true;
}
}
if(listOptions[2] == true){
Eif(urlAltered == true){
url = url + "&showPendingVeh=true";
}else{
url = url + "?showPendingVeh=true";
urlAltered = true;
}
}
Iif(listOptions[3] == true){
if(urlAltered == true){
url = url + "&showActiveVeh=true";
}else{
url = url + "?showActiveVeh=true";
urlAltered = true;
}
}
VehicleListService.getVehicleList(url).then(function(data){
$scope.myData.data = data;
Iif($scope.myData.data ==undefined){
$scope.myData.noDataFlg = true;
}
$scope.myData.loadDataFlg = false;
});
};
$scope.search = function() {
$scope.gridApi.grid.refresh();
but its not showing full coverage.
Can any one help on this by writing a test case

Related

How do I make the mobile back button close a modal without returning to the previous page?

On mobile, my modals cover the whole screen. They look exactly like whole new web pages. This leads to users getting confused. They expect to be able to press the back button and have the modal close. Instead the back button takes them back what they perceive as two steps.
I'm a novice at coding, so Javascript is all I've used for this, and even saying that feels like overselling my ability. I'm hoping you guys can help me figure this out.
Here's the code I used:
// Modals
// Modal Contact
function OpenModalContact () {
document.getElementById("Modal-Contact").style.display = "block";
}
// Modal-1 to 20
{
var modal1 = document.getElementById('Modal-01');
var modal2 = document.getElementById('Modal-02');
var modal3 = document.getElementById('Modal-03');
var modal4 = document.getElementById('Modal-04');
var modal5 = document.getElementById('Modal-05');
var modal6 = document.getElementById('Modal-06');
var modal7 = document.getElementById('Modal-07');
var modal8 = document.getElementById('Modal-08');
var modal9 = document.getElementById('Modal-09');
var modal10 = document.getElementById('Modal-10');
var modal11 = document.getElementById('Modal-11');
var modal12 = document.getElementById('Modal-12');
var modal13 = document.getElementById('Modal-13');
var modal14 = document.getElementById('Modal-14');
var modal15 = document.getElementById('Modal-15');
var modal16 = document.getElementById('Modal-16');
var modal17 = document.getElementById('Modal-17');
var modal18 = document.getElementById('Modal-18');
var modal19 = document.getElementById('Modal-19');
var modal20 = document.getElementById('Modal-20');
var modalContact = document.getElementById('Modal-Contact');
// Get the button that opens the modal
var Modalbtn01 = document.getElementById("ModalBtn01");
var Modalbtn02 = document.getElementById("ModalBtn02");
var Modalbtn03 = document.getElementById("ModalBtn03");
var Modalbtn04 = document.getElementById("ModalBtn04");
var Modalbtn05 = document.getElementById("ModalBtn05");
var Modalbtn06 = document.getElementById("ModalBtn06");
var Modalbtn07 = document.getElementById("ModalBtn07");
var Modalbtn08 = document.getElementById("ModalBtn08");
var Modalbtn09 = document.getElementById("ModalBtn09");
var Modalbtn10 = document.getElementById("ModalBtn10");
var Modalbtn11 = document.getElementById("ModalBtn11");
var Modalbtn12 = document.getElementById("ModalBtn12");
var Modalbtn13 = document.getElementById("ModalBtn13");
var Modalbtn14 = document.getElementById("ModalBtn14");
var Modalbtn15 = document.getElementById("ModalBtn15");
var Modalbtn16 = document.getElementById("ModalBtn16");
var Modalbtn17 = document.getElementById("ModalBtn17");
var Modalbtn18 = document.getElementById("ModalBtn18");
var Modalbtn19 = document.getElementById("ModalBtn19");
var Modalbtn20 = document.getElementById("ModalBtn20");
// Get the <span> element that closes the modal
var span1 = document.getElementById("CloseModal-01");
var span2 = document.getElementById("CloseModal-02");
var span3 = document.getElementById("CloseModal-03");
var span4 = document.getElementById("CloseModal-04");
var span5 = document.getElementById("CloseModal-05");
var span6 = document.getElementById("CloseModal-06");
var span7 = document.getElementById("CloseModal-07");
var span8 = document.getElementById("CloseModal-08");
var span9 = document.getElementById("CloseModal-09");
var span10 = document.getElementById("CloseModal-10");
var span11 = document.getElementById("CloseModal-11");
var span12 = document.getElementById("CloseModal-12");
var span13 = document.getElementById("CloseModal-13");
var span14 = document.getElementById("CloseModal-14");
var span15 = document.getElementById("CloseModal-15");
var span16 = document.getElementById("CloseModal-16");
var span17 = document.getElementById("CloseModal-17");
var span18 = document.getElementById("CloseModal-18");
var span19 = document.getElementById("CloseModal-19");
var span20 = document.getElementById("CloseModal-20");
var spanContact = document.getElementById("CloseModalContact");
// When the user clicks on the button, open the modal
ModalBtn01.onclick = function() {
modal1.style.display = "block";
}
ModalBtn02.onclick = function() {
modal2.style.display = "block";
}
ModalBtn03.onclick = function() {
modal3.style.display = "block";
}
ModalBtn04.onclick = function() {
modal4.style.display = "block";
}
ModalBtn05.onclick = function() {
modal5.style.display = "block";
}
ModalBtn06.onclick = function() {
modal6.style.display = "block";
}
ModalBtn07.onclick = function() {
modal7.style.display = "block";
}
ModalBtn08.onclick = function() {
modal8.style.display = "block";
}
ModalBtn09.onclick = function() {
modal9.style.display = "block";
}
ModalBtn10.onclick = function() {
modal10.style.display = "block";
}
ModalBtn11.onclick = function() {
modal11.style.display = "block";
}
ModalBtn12.onclick = function() {
modal12.style.display = "block";
}
ModalBtn13.onclick = function() {
modal13.style.display = "block";
}
ModalBtn14.onclick = function() {
modal14.style.display = "block";
}
ModalBtn15.onclick = function() {
modal15.style.display = "block";
}
ModalBtn16.onclick = function() {
modal16.style.display = "block";
}
ModalBtn17.onclick = function() {
modal17.style.display = "block";
}
ModalBtn18.onclick = function() {
modal18.style.display = "block";
}
ModalBtn19.onclick = function() {
modal19.style.display = "block";
}
ModalBtn20.onclick = function() {
modal20.style.display = "block";
}
// When the user clicks on <span> (x), close the modal
spanContact.onclick = function() {
modalContact.style.display = "none";
}
span1.onclick = function() {
modal1.style.display = "none";
}
span2.onclick = function() {
modal2.style.display = "none";
}
span3.onclick = function() {
modal3.style.display = "none";
}
span4.onclick = function() {
modal4.style.display = "none";
}
span5.onclick = function() {
modal5.style.display = "none";
}
span6.onclick = function() {
modal6.style.display = "none";
}
span7.onclick = function() {
modal7.style.display = "none";
}
span8.onclick = function() {
modal8.style.display = "none";
}
span9.onclick = function() {
modal9.style.display = "none";
}
span10.onclick = function() {
modal10.style.display = "none";
}
span11.onclick = function() {
modal11.style.display = "none";
}
span12.onclick = function() {
modal12.style.display = "none";
}
span13.onclick = function() {
modal13.style.display = "none";
}
span14.onclick = function() {
modal14.style.display = "none";
}
span15.onclick = function() {
modal15.style.display = "none";
}
span16.onclick = function() {
modal16.style.display = "none";
}
span17.onclick = function() {
modal17.style.display = "none";
}
span18.onclick = function() {
modal18.style.display = "none";
}
span19.onclick = function() {
modal19.style.display = "none";
}
span20.onclick = function() {
modal20.style.display = "none";
}
// When the user clicks anywhere outside of the modal, close it
window.onclick = function(event) {
if (event.target == modalContact) {
modalContact.style.display = "none";
}
if (event.target == modal1) {
modal1.style.display = "none";
}
if (event.target == modal2) {
modal2.style.display = "none";
}
if (event.target == modal3) {
modal3.style.display = "none";
}
if (event.target == modal4) {
modal4.style.display = "none";
}
if (event.target == modal5) {
modal5.style.display = "none";
}
if (event.target == modal6) {
modal6.style.display = "none";
}
if (event.target == modal7) {
modal7.style.display = "none";
}
if (event.target == modal8) {
modal8.style.display = "none";
}
if (event.target == modal9) {
modal9.style.display = "none";
}
if (event.target == modal10) {
modal10.style.display = "none";
}
if (event.target == modal11) {
modal11.style.display = "none";
}
if (event.target == modal12) {
modal12.style.display = "none";
}
if (event.target == modal13) {
modal13.style.display = "none";
}
if (event.target == modal14) {
modal14.style.display = "none";
}
if (event.target == modal15) {
modal15.style.display = "none";
}
if (event.target == modal16) {
modal16.style.display = "none";
}
if (event.target == modal17) {
modal17.style.display = "none";
}
if (event.target == modal18) {
modal18.style.display = "none";
}
if (event.target == modal19) {
modal19.style.display = "none";
}
if (event.target == modal20) {
modal20.style.display = "none";
}
}
}
// Close modal on ESC key press
document.addEventListener("keydown", function(event) {
if (event.keyCode === 27 &&
(document.querySelector("#Modal-Contact").style.display === "block" ||
document.querySelector("#Modal-01").style.display === "block" ||
document.querySelector("#Modal-02").style.display === "block" ||
document.querySelector("#Modal-03").style.display === "block" ||
document.querySelector("#Modal-04").style.display === "block" ||
document.querySelector("#Modal-05").style.display === "block" ||
document.querySelector("#Modal-06").style.display === "block" ||
document.querySelector("#Modal-07").style.display === "block" ||
document.querySelector("#Modal-08").style.display === "block" ||
document.querySelector("#Modal-09").style.display === "block" ||
document.querySelector("#Modal-10").style.display === "block" ||
document.querySelector("#Modal-11").style.display === "block" ||
document.querySelector("#Modal-12").style.display === "block" ||
document.querySelector("#Modal-13").style.display === "block" ||
document.querySelector("#Modal-14").style.display === "block" ||
document.querySelector("#Modal-15").style.display === "block" ||
document.querySelector("#Modal-16").style.display === "block" ||
document.querySelector("#Modal-17").style.display === "block" ||
document.querySelector("#Modal-18").style.display === "block" ||
document.querySelector("#Modal-19").style.display === "block" ||
document.querySelector("#Modal-20").style.display === "block" ))
{
document.querySelector("#Modal-Contact").style.display = "none";
document.querySelector("#Modal-01").style.display = "none";
document.querySelector("#Modal-02").style.display = "none";
document.querySelector("#Modal-03").style.display = "none";
document.querySelector("#Modal-04").style.display = "none";
document.querySelector("#Modal-05").style.display = "none";
document.querySelector("#Modal-06").style.display = "none";
document.querySelector("#Modal-07").style.display = "none";
document.querySelector("#Modal-08").style.display = "none";
document.querySelector("#Modal-09").style.display = "none";
document.querySelector("#Modal-10").style.display = "none";
document.querySelector("#Modal-11").style.display = "none";
document.querySelector("#Modal-12").style.display = "none";
document.querySelector("#Modal-13").style.display = "none";
document.querySelector("#Modal-14").style.display = "none";
document.querySelector("#Modal-15").style.display = "none";
document.querySelector("#Modal-16").style.display = "none";
document.querySelector("#Modal-17").style.display = "none";
document.querySelector("#Modal-18").style.display = "none";
document.querySelector("#Modal-19").style.display = "none";
document.querySelector("#Modal-20").style.display = "none";
}
});
// Close modal on back button for mobile
document.addEventListener("backbutton", function(event) {
if
(document.querySelector("#Modal-Contact").style.display === "block" ||
document.querySelector("#Modal-01").style.display === "block" ||
document.querySelector("#Modal-02").style.display === "block" ||
document.querySelector("#Modal-03").style.display === "block" ||
document.querySelector("#Modal-04").style.display === "block" ||
document.querySelector("#Modal-05").style.display === "block" ||
document.querySelector("#Modal-06").style.display === "block" ||
document.querySelector("#Modal-07").style.display === "block" ||
document.querySelector("#Modal-08").style.display === "block" ||
document.querySelector("#Modal-09").style.display === "block" ||
document.querySelector("#Modal-10").style.display === "block" ||
document.querySelector("#Modal-11").style.display === "block" ||
document.querySelector("#Modal-12").style.display === "block" ||
document.querySelector("#Modal-13").style.display === "block" ||
document.querySelector("#Modal-14").style.display === "block" ||
document.querySelector("#Modal-15").style.display === "block" ||
document.querySelector("#Modal-16").style.display === "block" ||
document.querySelector("#Modal-17").style.display === "block" ||
document.querySelector("#Modal-18").style.display === "block" ||
document.querySelector("#Modal-19").style.display === "block" ||
document.querySelector("#Modal-20").style.display === "block" )
{
document.querySelector("#Modal-Contact").style.display = "none";
document.querySelector("#Modal-01").style.display = "none";
document.querySelector("#Modal-02").style.display = "none";
document.querySelector("#Modal-03").style.display = "none";
document.querySelector("#Modal-04").style.display = "none";
document.querySelector("#Modal-05").style.display = "none";
document.querySelector("#Modal-06").style.display = "none";
document.querySelector("#Modal-07").style.display = "none";
document.querySelector("#Modal-08").style.display = "none";
document.querySelector("#Modal-09").style.display = "none";
document.querySelector("#Modal-10").style.display = "none";
document.querySelector("#Modal-11").style.display = "none";
document.querySelector("#Modal-12").style.display = "none";
document.querySelector("#Modal-13").style.display = "none";
document.querySelector("#Modal-14").style.display = "none";
document.querySelector("#Modal-15").style.display = "none";
document.querySelector("#Modal-16").style.display = "none";
document.querySelector("#Modal-17").style.display = "none";
document.querySelector("#Modal-18").style.display = "none";
document.querySelector("#Modal-19").style.display = "none";
document.querySelector("#Modal-20").style.display = "none";
event.preventDefault();
}
});
I've incorporated this, event.preventDefault(); but it doesn't seem to work
I hoped it would prevent the back button from doing it's default behaviour.
I've seen a post on here about something like this:
https://stackoverflow.com/a/49954532/18237477
But I'm unable to incorporate that solution into my code. Their code probably works but I don't understand it. I don't know how to merge that code into mine.

how to set func with boolean?

I'm stuck validating textfields on the form screen. I don't want to allow requests to be thrown even if one of the textfields is empty. I want to show warning message for empty textfield. If all conditions are met, I would like to submit a request.
func isValid() -> Bool {
if nameTextField.text?.isEmpty == false {
nameWarningLabel.isHidden = true
nameTextField.layer.borderColor = R.color.rgb_222_222_222()?.cgColor
}
else {
nameWarningLabel.isHidden = false
nameTextField.layer.borderColor = R.color.rgb_249_36_23()?.cgColor
}
if surnameTextField.text?.isEmpty == false {
surnameWarningLabel.isHidden = true
surnameTextField.layer.borderColor = R.color.rgb_222_222_222()?.cgColor
}
else {
surnameWarningLabel.isHidden = false
surnameTextField.layer.borderColor = R.color.rgb_249_36_23()?.cgColor
}
if cellPhoneTextField.text?.isEmpty == false {
phoneWarningLabel.isHidden = true
cellPhoneTextField.layer.borderColor = R.color.rgb_222_222_222()?.cgColor
}
else {
phoneWarningLabel.isHidden = false
cellPhoneTextField.layer.borderColor = R.color.rgb_249_36_23()?.cgColor
}
if isChecked == true {
agreementCheckBoxButton.layer.borderColor = R.color.rgb_222_222_222()?.cgColor
}
else {
agreementCheckBoxButton.layer.borderColor = R.color.rgb_249_36_23()?.cgColor
}
if isChecked == true || (nameTextField.text?.count ?? 0) > 2 || (surnameTextField.text?.count ?? 0) > 2 || (cellPhoneTextField.text?.count ?? 0) < 10 {
return true
}
else {
return false
}
}
If this function returns true or false, I will send a request to the
service.
I am sharing the code block with you below
Create a BOOL variable within your function. Set the default value to true, and when it runs into an else condition, set it to false. Finally, at the end of your function, return the value of your BOOL variable. If all of the positive conditions are met, it will return the default value of true, otherwise return false.
func isValid() -> Bool {
//Declare Variable
var sendRequest:Bool = true
//Check Name Text Field
if nameTextField.text?.isEmpty == false {
nameWarningLabel.isHidden = true
nameTextField.layer.borderColor = R.color.rgb_222_222_222()?.cgColor
} else {
nameWarningLabel.isHidden = false
nameTextField.layer.borderColor = R.color.rgb_249_36_23()?.cgColor
sendRequest = false
}
//Check Surname Text Field
if surnameTextField.text?.isEmpty == false {
surnameWarningLabel.isHidden = true
surnameTextField.layer.borderColor = R.color.rgb_222_222_222()?.cgColor
} else {
surnameWarningLabel.isHidden = false
surnameTextField.layer.borderColor = R.color.rgb_249_36_23()?.cgColor
sendRequest = false
}
//Check Cell Phone Text Field
if cellPhoneTextField.text?.isEmpty == false {
phoneWarningLabel.isHidden = true
cellPhoneTextField.layer.borderColor = R.color.rgb_222_222_222()?.cgColor
} else {
phoneWarningLabel.isHidden = false
cellPhoneTextField.layer.borderColor = R.color.rgb_249_36_23()?.cgColor
sendRequest = false
}
//Check Agreement Check Box
if isChecked == true {
agreementCheckBoxButton.layer.borderColor = R.color.rgb_222_222_222()?.cgColor
} else {
agreementCheckBoxButton.layer.borderColor = R.color.rgb_249_36_23()?.cgColor
sendRequest = false
}
//Return Variable
return sendRequest
}

how to run a stream in different thread in dart

Future<bool> checkConnection() async {
var connectivityResult = await (Connectivity().checkConnectivity());
bool connOk = false;
if (connectivityResult == ConnectivityResult.mobile) {
bool ii = await checkConnectionWithUrl();
if (ii == true) {
connOk = true;
}
} else if (connectivityResult == ConnectivityResult.wifi) {
bool ii = await checkConnectionWithUrl();
if (ii == true) {
connOk = true;
}
} else if (connectivityResult == ConnectivityResult.ethernet) {
bool ii = await checkConnectionWithUrl();
if (ii == true) {
connOk = true;
}
} else if (connectivityResult == ConnectivityResult.bluetooth) {
bool ii = await checkConnectionWithUrl();
if (ii == true) {
connOk = true;
}
} else {
connOk = false;
}
return connOk;
}
Future<bool> checkConnectionWithUrl() async {
bool response = false;
while (true) {
var checkin = await client.get(Uri.https('www.google.com', '/'));
if (checkin.statusCode == 200) {
response = true;
break;
} else {
sleep(const Duration(milliseconds: 500));
}
}
return response;
}
Stream checkStream() async* {
dynamic result = false;
while (true) {
try {
result = await checkConnection();
} catch (error) {
result = false;
} finally {
yield result;
}
await Future.delayed(const Duration(seconds: 1));
}
}
I am making a app. And I want to learn multi threading in dart. The above function what it will do is it look for wifi state every second and update the Ui. But when I run the function it will drop frams in ui. So I what to run it in a diffrent thread. can i do it.
---My main goal ---
I want to run this function in a different thread how do I do it

Using Toggle in a password field in jetpack compose

I am trying to use toggle in a password field. This is my code so far but for some reason it wont work. How can I achieve toggling a password as in this image? Much appreciated!
Image: https://gyazo.com/5ad35b44dc955e0846c68f61ec9630b0
Column(
modifier = Modifier.padding(20.dp),
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally
) {
val username = remember { mutableStateOf(TextFieldValue()) }
val password = remember { mutableStateOf("") }
var revealPassword: MutableState<Boolean> =
remember { mutableStateOf(false) } // To reveal the password with toggle
Text(text = "Sign in", style = TextStyle(fontSize = 40.sp, fontFamily = FontFamily.Cursive))
Text(
text = "here",
style = TextStyle(fontSize = 40.sp, fontFamily = FontFamily.Cursive)
)
// PASSWORD
Spacer(modifier = Modifier.height(20.dp))
OutlinedTextField(
value = password.value,
onValueChange = { newText ->
password.value = newText
},
visualTransformation = if (revealPassword.value) {
VisualTransformation.None
} else {
PasswordVisualTransformation()
},
trailingIcon = {
if (revealPassword.value) {
IconButton(onClick = {
(I changed this!! -->) revealPassword.Value = false
}) { Icon(imageVector = Icons.Filled.Visibility, contentDescription = null) }
} else {
IconButton(onClick = {
(I changed this!! -->) revealPassword.Value = true }) {
Icon(imageVector = Icons.Filled.VisibilityOff, contentDescription = null)
}
}
},
label = { Text(text = "Password") },
singleLine = true,
leadingIcon = { Icon(imageVector = Icons.Default.Lock, contentDescription = null) },
modifier = Modifier
.fillMaxWidth(180F),
)
You have given revealPassword = true in both onClick().
Change the first one to revealPassword = false
Complete code
#Composable
fun TogglePassword() {
val password = remember {
mutableStateOf("")
}
var revealPassword: MutableState<Boolean> = remember {
mutableStateOf(false)
} // To reveal the password with toggle
OutlinedTextField(
value = password.value,
onValueChange = { newText ->
password.value = newText
},
visualTransformation = if (revealPassword.value) {
VisualTransformation.None
} else {
PasswordVisualTransformation()
},
trailingIcon = {
if (revealPassword.value) {
IconButton(
onClick = {
revealPassword.value = false
},
) {
Icon(imageVector = Icons.Filled.Visibility, contentDescription = null)
}
} else {
IconButton(
onClick = {
revealPassword.value = true
},
) {
Icon(imageVector = Icons.Filled.VisibilityOff, contentDescription = null)
}
}
},
label = {
Text(text = "Password")
},
singleLine = true,
leadingIcon = {
Icon(imageVector = Icons.Default.Lock, contentDescription = null)
},
modifier = Modifier
.fillMaxWidth()
.padding(16.dp),
)
}
You are setting boolean wrong.
And I think it is cleaner to control VisualTransformation above.
#Composable
fun PasswordTextField() {
var masked by remember {
mutableStateOf(false)
}
var password by remember {
mutableStateOf("")
}
val visualTransformation by remember(masked) {
if (masked)
mutableStateOf(PasswordVisualTransformation())
else
mutableStateOf(VisualTransformation.None)
}
OutlinedTextField(
value = password,
onValueChange = { newText ->
password = newText
},
visualTransformation = visualTransformation,
trailingIcon = {
if (masked) {
IconButton(onClick = {
masked = false
}) { Icon(imageVector = Icons.Filled.VisibilityOff, contentDescription = null) }
} else {
IconButton(onClick = { masked = true }) {
Icon(imageVector = Icons.Filled.Visibility, contentDescription = null)
}
}
},
label = { Text(text = "Password") },
singleLine = true,
modifier = Modifier
.fillMaxWidth(.1f),
)
}

My function just keeps looping, is it something to do with firestore?

My function is just looping at the print statement and not going into the ref db.collection Am I doing something wrong here? Thank you for any help. Im not really sure where to go, is this the best way to loop throw most of the data
func rat(){
var x = 0
while x != self.uniqueNumber{
let db = Firestore.firestore()
let indexString = String(x)
print(x)
let ref = db.collection("leaderboard").document(indexString)
ref.getDocument { (document,error) in
if error != nil{
print("cant get data")
}
if document != nil && document!.exists{
if let documentdata = document?.data() {
self.check = documentdata["points"] as! Int
self.uid = documentdata["uid"] as! String
x = x+1
print(x)
print("The user's ID was\(self.uid)")
if (self.check > self.firstPlace.placePoints){
self.secondPlace.placePoints = self.firstPlace.placePoints
self.secondPlace.placeNames = self.firstPlace.placeNames
self.firstPlace.placePoints = self.check
self.firstPlace.placeNames = self.uid
print("First Place was set to:\(self.firstPlace.placeNames)")
}else if(self.check < self.firstPlace.placePoints && self.secondPlace.placePoints < self.check){
self.thirdPlace.placePoints = self.secondPlace.placePoints
self.thirdPlace.placeNames = self.secondPlace.placeNames
self.secondPlace.placePoints = self.check
self.secondPlace.placeNames = self.uid
print("Second Place was set to:\(self.firstPlace.placeNames)")
}else if(self.check < self.secondPlace.placePoints && self.thirdPlace.placePoints < self.check){
self.thirdPlace.placePoints = self.check
self.thirdPlace.placeNames = self.uid
print("Third Place was set to:\(self.firstPlace.placeNames)")
}
}
if(x == self.uniqueNumber!-1){
print("This is the escape out")
self.setGuys()
}
}
}
}
}
Maybe you can try move the while x != self.uniqueNumber to inside the getDocument
func rat(){
var x = 0
let db = Firestore.firestore()
let indexString = String(x)
let ref = db.collection("leaderboard").document(indexString)
ref.getDocument { (document,error) in
if error != nil{
print("cant get data")
}
while x != self.uniqueNumber {
if document != nil && document!.exists{
if let documentdata = document?.data() {
x = x+1
}
if(x == self.uniqueNumber!-1){
self.setGuys()
}
}
}
}
}