Skip to content

Commit

Permalink
Fix test login (maybe) (#90)
Browse files Browse the repository at this point in the history
* maybe fix test login

* move if statement up

* test login button

* revert to 285d808 (undo button commit)

* add comment for reference
  • Loading branch information
solderq35 authored Apr 4, 2024
1 parent 5617318 commit 840e5ee
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 12 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
9 changes: 9 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,16 @@ module.exports = function (api) {
return {
presets: ["babel-preset-expo", "module:metro-react-native-babel-preset"],
plugins: [
// Fix issues with test login script (yarn test), and build cache
// Reference: https://github.com/expo/router/issues/41#issuecomment-1657674119
[
"transform-inline-environment-variables",
{
include: ["EXPO_ROUTER_APP_ROOT"],
},
],
require.resolve("expo-router/babel"),
"@babel/plugin-transform-export-namespace-from",
"react-native-paper/babel",
"react-native-reanimated/plugin",
[
Expand Down
21 changes: 12 additions & 9 deletions context/Auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,20 @@ export const AuthProvider = ({ children }) => {
//if this code is not in here, it'll run for infinite times
onAuthStateChanged(auth, (currentUserId) => {
console.log("user changed");
if (currentUserId) {
setCurrentUserId(currentUserId.uid ?? "Error (uid)");

// test user login (yarn test)
// If you sign out, reload app to sign back in as test user
if (process.env.EXPO_PUBLIC_TEST_UID) {
setCurrentUserId(process.env.EXPO_PUBLIC_TEST_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
if (process.env.EXPO_PUBLIC_TEST_UID) {
setCurrentUserId(process.env.EXPO_PUBLIC_TEST_UID);
}
// regular user login
else {
if (currentUserId) {
setCurrentUserId(currentUserId.uid ?? "Error (uid)");
}
}
});
}, []);
return (
<AuthContext.Provider
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"devDependencies": {
"@babel/core": "^7.20.0",
"@tanstack/eslint-plugin-query": "^5.20.1",
"babel-plugin-transform-inline-environment-variables": "^0.4.4",
"prettier": "3.2.5",
"prettier-plugin-organize-imports": "^3.2.4"
},
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3523,6 +3523,11 @@ babel-plugin-transform-flow-enums@^0.0.2:
dependencies:
"@babel/plugin-syntax-flow" "^7.12.1"

babel-plugin-transform-inline-environment-variables@^0.4.4:
version "0.4.4"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-inline-environment-variables/-/babel-plugin-transform-inline-environment-variables-0.4.4.tgz#974245008b3cbbd646bd81707af147aea3acca43"
integrity sha512-bJILBtn5a11SmtR2j/3mBOjX4K3weC6cq+NNZ7hG22wCAqpc3qtj/iN7dSe9HDiS46lgp1nHsQgeYrea/RUe+g==

babel-preset-expo@~9.5.2:
version "9.5.2"
resolved "https://registry.yarnpkg.com/babel-preset-expo/-/babel-preset-expo-9.5.2.tgz#5ed1756c8434ca972d7a940e4f13570a283641df"
Expand Down

0 comments on commit 840e5ee

Please sign in to comment.