diff --git a/website/public/team/scripts.js b/website/public/team/scripts.js index 8f98c0cd..e2cb0b97 100644 --- a/website/public/team/scripts.js +++ b/website/public/team/scripts.js @@ -140,27 +140,26 @@ function reqjt(tn, tc) { function leaveTeam(tn) { teamAssoc = firebase.firestore().collection('UserAssociations').doc(user.uid) teamAssoc.get().then(function(doc) { - if (doc.exists) { - list = doc.data() - delete list[tn] - firebase.firestore().collection("UserAssociations").doc(user.uid).set(list).then(function() { - teamAssoc = firebase.firestore().collection('UserAssociations').doc(user.uid) - teamAssoc.get().then(function(doc) { - if (doc.exists) { - list = doc.data() - teamNums = Object.keys(list) - document.getElementById('teammem').innerHTML = "" - for (var i = 0; i < teamNums.length; i++) { - document.getElementById('teammem').innerHTML += "" + teamNums[i] + "" + list[teamNums[i]] + "" + "" - } - } else { - document.getElementById('teammem').innerHTML = "You are not part of any teams" + if (doc.exists) { + list = doc.data() + delete list[tn] + firebase.firestore().collection("UserAssociations").doc(user.uid).set(list).then(function() { + teamAssoc = firebase.firestore().collection('UserAssociations').doc(user.uid) + teamAssoc.get().then(function(doc) { + if (doc.exists) { + list = doc.data() + teamNums = Object.keys(list) + document.getElementById('teammem').innerHTML = "" + for (var i = 0; i < teamNums.length; i++) { + document.getElementById('teammem').innerHTML += "" + teamNums[i] + "" + list[teamNums[i]] + "" + "" } - }) + } else { + document.getElementById('teammem').innerHTML = "You are not part of any teams" + } }) - ) + }) } - } + }) function signout() { var user = firebase.auth().currentUser;