From 045a4f0689869bc9d06f2eda12911d17568a4733 Mon Sep 17 00:00:00 2001 From: Frank Nguyen <41023671+FrankreedX@users.noreply.github.com> Date: Mon, 12 Aug 2024 21:36:54 +0700 Subject: [PATCH] fixed "invalid-argument" (#307) --- app/content/team/users/[user]/index.js | 2 ++ dbOperations/removeUser.js | 10 +++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/content/team/users/[user]/index.js b/app/content/team/users/[user]/index.js index f1488bcc..a5c0ba64 100644 --- a/app/content/team/users/[user]/index.js +++ b/app/content/team/users/[user]/index.js @@ -321,6 +321,7 @@ function Index() { navigation.goBack(); } catch (e) { console.log("Error removing user:", e); + hideRemoveDialog(); showDialog("Error", getErrorString(e)); } }, @@ -346,6 +347,7 @@ function Index() { navigation.goBack(); } catch (e) { console.log("Error banning user:", e); + hideBanDialog(); showDialog("Error", getErrorString(e)); } }, diff --git a/dbOperations/removeUser.js b/dbOperations/removeUser.js index f167b072..b7129c4f 100644 --- a/dbOperations/removeUser.js +++ b/dbOperations/removeUser.js @@ -22,6 +22,11 @@ async function removeUser(teamId, userId) { const attemptSnapshot = await getDocs(attemptQuery); + //Remove user from user table where UID == userID + const userRef = doc(db, "teams", teamId, "users", userId); + + const userSnapshot = await transaction.get(userRef); + for (const doc of attemptSnapshot.docs) { await transaction.delete(doc.ref); } @@ -44,11 +49,6 @@ async function removeUser(teamId, userId) { } } - //Remove user from user table where UID == userID - const userRef = doc(db, "teams", teamId, "users", userId); - - const userSnapshot = await transaction.get(userRef); - //remove pfp if there is one if (userSnapshot.data().pfp !== "") { await removePfp(getPfpName(teamId, userId));