Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maintained unused code in a separate file. #169

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ grounded-*
# macOS
.DS_Store
yarn.lock

# Ignore unused code file
UnUsedCode.tsx

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You shouldn't keep UnUsedCode, if it's unused, just remove it (from your clone of the repo and from .gitignore).
I like the idea of cleaning up the unused code by deleting it. Thanks for keeping things clean.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, Dr. Holdener, I will remove it.

4 changes: 2 additions & 2 deletions __tests__/__snapshots__/SetTime.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ exports[`LocationWindow renders without crashing 1`] = `
}
}
>
9/16/2024
11:31 AM
9/23/2024
02:35 PM
</Text>
</View>
<View
Expand Down
41 changes: 0 additions & 41 deletions lib/models/user_class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ export class User {
private userData: UserData | null = null;
private callback: ((isLoggedIn: boolean) => void) | null = null;



public static getInstance(): User {
if (!User.instance) {
User.instance = new User();
Expand Down Expand Up @@ -61,52 +59,15 @@ export class User {

public async login(username: string, password: string): Promise<string> {
try {



// const response = await fetch(
// "https://lived-religion-dev.rerum.io/deer-lr/login",
// {
// method: "POST",
// mode: "cors",
// cache: "no-cache",
// headers: {
// "Content-Type": "application/json;charset=utf-8",
// },
// body: JSON.stringify({
// username: username,
// password: password,
// }),
// }
// );


// if (response.ok) {
// const data = await response.json();
// this.userData = data;
// if (this.userData !== null) {
// await this.persistUser(this.userData);
// }
// this.notifyLoginState();
// console.log("From userClass, Data ***************************==>>************************************ ", this.userData)
// return "success";
// } else {
// throw new Error("There was a server error logging in.");
// }

const userCredential = await signInWithEmailAndPassword(auth, username, password);
const user = userCredential.user;
// const token = await user.getIdToken();
// console.log("user id is ", user.uid)
const userData = await ApiService.fetchUserData(user.uid)

if (userData) {
this.userData = userData;
console.log("user data ", userData)
await this.persistUser(userData);

}

this.notifyLoginState();

return "success";
Expand All @@ -131,8 +92,6 @@ export class User {
dispatch(setNavState("login"))
this.clearUser();
this.notifyLoginState();

// console.log("User logged out");
}
})
.catch((err) => {
Expand Down
2 changes: 1 addition & 1 deletion lib/navigation/AppNavigator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const HomeStack = () => {
};

const AppNavigator: React.FC = () => {
// const [navState, setNavState] = useState<"loading" | "onboarding" | "login" | "home">("loading");

const { theme, isDarkmode } = useTheme();
const dispatch = useDispatch();
const navState = useSelector((state: RootState) => state.navigation.navState);
Expand Down
2 changes: 0 additions & 2 deletions lib/screens/HomeScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,6 @@ const HomeScreen: React.FC<HomeScreenProps> = ({ navigation, route }) => {
backgroundColor: theme.homeGray,
width: "50%",
right: 0,
// borderTopRightRadius: 20,
// borderBottomRightRadius: 20,
},
rowBack: {
width: "100%",
Expand Down
26 changes: 2 additions & 24 deletions lib/screens/loginScreens/LoginScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,11 @@ import {
import { KeyboardAwareScrollView } from "react-native-keyboard-aware-scroll-view";
import * as SplashScreen from "expo-splash-screen";
import { Snackbar } from "react-native-paper";
import { signInWithEmailAndPassword } from "firebase/auth";
import { auth } from "../../config"; // Import the Firebase auth
import { User } from "../../models/user_class";
import { removeItem } from "../../utils/async_storage";
import { useSelector, useDispatch } from 'react-redux';
import { setNavState } from "../../../redux/slice/navigationSlice";
import { RootState } from "../../../redux/store/store";
import { Keyboard } from "react-native";

const user = User.getInstance();

Expand Down Expand Up @@ -55,34 +52,24 @@ const LoginScreen: React.FC<LoginProps> = ({ navigation, route }) => {
return () => clearTimeout(timer);
}, []);

console.log("in login page the redux value is ", navState)

useEffect(() => {
(async () => {
await SplashScreen.preventAutoHideAsync();
await SplashScreen.hideAsync();
})();
}, []);

const handleGoRegister = () => {
navigation.navigate("Register");
};

const onDismissSnackBar = () => toggleSnack(false);

const handleLogin = async () => {

if (username === "" || password === "") {
toggleSnack(!snackState);
} else {

// changes made by karthik

}
else {
try {
const status = await user.login(username, password)
if (status == "success") {
const userId = await user.getId();
// console.log("in login page, Inside the is statement of success ", userId)
if (userId !== null) {
setUsername("")
setPassword("")
Expand All @@ -101,15 +88,6 @@ const LoginScreen: React.FC<LoginProps> = ({ navigation, route }) => {
}
};

const clearOnboarding = async () => {
try {
await removeItem("onboarded");
console.log("Onboarding key cleared!");
} catch (error) {
console.error("Failed to clear the onboarding key.", error);
}
};

const onLoginPress = async () => {
try {
await handleLogin();
Expand Down
12 changes: 0 additions & 12 deletions lib/screens/mapPage/ExploreScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ const ExploreScreen = () => {
region: newRegion,
}));

// _map.current.animateToRegion(newRegion, 350);
}
setSearchResults(searchResults);
});
Expand All @@ -93,17 +92,6 @@ const ExploreScreen = () => {
"someUserId"
);

// console.log("STEP 3: fetchedNotes from ApiService.fetchMessages:", fetchedNotes);

// Write the count to the log file
// await RNFS.appendFile(logFilePath, `Count of fetched notes: ${fetchedNotes.length}\n`, 'utf8')
// .then(() => {
// console.log('Logged count to file');
// })
// .catch(err => {
// console.error('Error writing to log file:', err);
// });


const fetchedMarkers = fetchedNotes.map((note) => {
let time;
Expand Down