From 18490bd8b0d85b625de896870f46ab594b116143 Mon Sep 17 00:00:00 2001 From: solderq35 Date: Mon, 1 Apr 2024 14:09:40 -0700 Subject: [PATCH] maybe fix test login --- app/segments/drill/[id]/submission/input.js | 6 +++--- context/Auth.js | 11 ++++++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/app/segments/drill/[id]/submission/input.js b/app/segments/drill/[id]/submission/input.js index 204908c4..afee1c9e 100644 --- a/app/segments/drill/[id]/submission/input.js +++ b/app/segments/drill/[id]/submission/input.js @@ -418,7 +418,7 @@ export default function Input({ drillInfo, setToggleResult, setOutputData }) { { - descriptionModalRef.current ?.present(); + descriptionModalRef.current?.present(); }} color={"#F24E1E"} /> @@ -468,7 +468,7 @@ export default function Input({ drillInfo, setToggleResult, setOutputData }) { icon={getIconByKey(item.id)} prompt={item.prompt} distanceMeasure={item.distanceMeasure} - inputValue={inputValues[displayedShot] ?.[item.id] || ""} + inputValue={inputValues[displayedShot]?.[item.id] || ""} onInputChange={(newText) => { handleInputChange(item.id, newText); }} @@ -573,7 +573,7 @@ export default function Input({ drillInfo, setToggleResult, setOutputData }) { { - navModalRef.current ?.present(); + navModalRef.current?.present(); }} > View all shots diff --git a/context/Auth.js b/context/Auth.js index b6b8bac0..7860f36f 100644 --- a/context/Auth.js +++ b/context/Auth.js @@ -45,15 +45,20 @@ export const AuthProvider = ({ children }) => { useEffect(() => { //if this code is not in here, it'll run for infinite times onAuthStateChanged(auth, (currentUserId) => { + // keep this log outside if statement to confirm e.g. logout of test user console.log("user changed"); - if (currentUserId) { - setCurrentUserId(currentUserId.uid ?? "Error (uid)"); + + // prevent "persistent login" of regular user login from conflicting with test user + if (!process.env.EXPO_PUBLIC_TEST_UID) { + if (currentUserId) { + setCurrentUserId(currentUserId.uid ?? "Error (uid)"); + } } }); // yarn test // If you sign out, reload app to sign back in as test user - // Moved outside of useEffect to avoid race condition with logout + // Moved outside of onAuthChanged to avoid race condition with logout if (process.env.EXPO_PUBLIC_TEST_UID) { setCurrentUserId(process.env.EXPO_PUBLIC_TEST_UID); }