Skip to content

Commit

Permalink
maybe fix test login
Browse files Browse the repository at this point in the history
  • Loading branch information
solderq35 committed Apr 1, 2024
1 parent 5617318 commit 18490bd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
6 changes: 3 additions & 3 deletions app/segments/drill/[id]/submission/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ export default function Input({ drillInfo, setToggleResult, setOutputData }) {
<Appbar.Action
icon="information-outline"
onPress={() => {
descriptionModalRef.current ?.present();
descriptionModalRef.current?.present();
}}
color={"#F24E1E"}
/>
Expand Down Expand Up @@ -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);
}}
Expand Down Expand Up @@ -573,7 +573,7 @@ export default function Input({ drillInfo, setToggleResult, setOutputData }) {
<Text
style={{ color: "#F3572A" }}
onPress={() => {
navModalRef.current ?.present();
navModalRef.current?.present();
}}
>
View all shots
Expand Down
11 changes: 8 additions & 3 deletions context/Auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 18490bd

Please sign in to comment.