Skip to content

Commit

Permalink
IWB-4: User is navigated off of chooseTeam once they're accepted thro…
Browse files Browse the repository at this point in the history
…ugh waitlist (#312)

* added blacklist hook

* black list feature works

* some unused stuff removal

* waitlist seems to work

* simplified removeBlacklist.js

* pretty

* removed transaction and hope that it works

* fixed useBlackList.js hook firestore error, and made blacklist check functional

* added refresh spinner for chooseTeam.js

* updated invalidateKeys and fixed some styling

* updated faulty invalidateKeys lists

* kinda works lmao

* updated the invalidateKeys again

* navigation off chooseTeam works. Tech debt +1

* added waitlistError to ErrorComponent

* minor comment change

Co-authored-by: Jake Gehrke <91503842+Gehrkej@users.noreply.github.com>

* changed console log wording in removeBlacklist

Co-authored-by: Jake Gehrke <91503842+Gehrkej@users.noreply.github.com>

* removed copied over comment

* updated tiny comment

Co-authored-by: Jake Gehrke <91503842+Gehrkej@users.noreply.github.com>

* removed redundant log

Co-authored-by: Jake Gehrke <91503842+Gehrkej@users.noreply.github.com>

* fix - added email to blacklist record

* fix - added assertion if pfp exists when removing a user

* prevent double navigation to chooseTeam screen

* fixed "invalid-argument"

* added key

* removed redundant remove user fix

* pretty

* pretty

* pretty

* added missing state from merge

* simple fix

---------

Co-authored-by: Jake Gehrke <91503842+Gehrkej@users.noreply.github.com>
Co-authored-by: Jake Gehrke <gehrkej@oregonstate.edu>
  • Loading branch information
3 people committed Aug 15, 2024
1 parent ad07383 commit 65b8beb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 4 additions & 0 deletions app/segments/(team)/chooseTeam.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { useAuthContext } from "~/context/Auth";
import { addToTeam } from "~/dbOperations/addToTeam";
import { addToWaitlist } from "~/dbOperations/addToWaitlist";
import { useBlackList } from "~/dbOperations/hooks/useBlackList";
import { useUserInfo } from "~/dbOperations/hooks/useUserInfo";
import { useWaitlist } from "~/dbOperations/hooks/useWaitlist";
import { invalidateMultipleKeys } from "~/dbOperations/invalidateMultipleKeys";
import { auth } from "~/firebaseConfig";
Expand Down Expand Up @@ -46,6 +47,9 @@ function ChooseTeam() {
isLoading: waitlistIsLoading,
} = useWaitlist();

//basically to trigger the side effect that navigates off this page
useUserInfo({ userId: currentUserId });

const state = useMemo(() => {
if (blacklist && blacklist[currentUserId]) {
return "blacklist";
Expand Down
11 changes: 9 additions & 2 deletions dbOperations/hooks/useUserInfo.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useQuery } from "@tanstack/react-query";
import { router } from "expo-router";
import { router, useSegments } from "expo-router";
import {
collection,
doc,
Expand All @@ -18,6 +18,7 @@ export const useUserInfo = ({
role = null,
enabled = true,
} = {}) => {
const segments = useSegments();
const { currentTeamId, currentUserId, currentUserVerified } =
useAuthContext();
const week_milliseconds = 604800000;
Expand All @@ -44,8 +45,10 @@ export const useUserInfo = ({
console.log("e", getErrorString(e));
}

const inChooseTeam = segments.at(-1) === "chooseTeam";

if (!data || !currentUserVerified) {
if (currentUserId === userId) {
if (currentUserId === userId && !inChooseTeam) {
router.replace("segments/(team)/chooseTeam");
}
return {
Expand All @@ -57,6 +60,10 @@ export const useUserInfo = ({
uniqueDrills: [],
};
}
if (inChooseTeam) {
router.replace("content/assignments");
}

const filteredAssignedData = data.assigned_data.filter((assignment) => {
const timeDifference = currentDateTime - assignment.assignedTime;
return timeDifference <= week_milliseconds;
Expand Down

0 comments on commit 65b8beb

Please sign in to comment.