Skip to content

Commit

Permalink
mobile: SignIn: use promise resolution instead of try-catch
Browse files Browse the repository at this point in the history
  • Loading branch information
ericswpark committed Feb 25, 2024
1 parent 83d4e2b commit dddf409
Showing 1 changed file with 26 additions and 15 deletions.
41 changes: 26 additions & 15 deletions mobile/Screens/SignIn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,36 @@ export const SignIn = (props) => {
Keyboard.dismiss();
};
const handleSignIn = () => {
try {
account.createEmailSession(email, password).then((session) => {
account
.createEmailSession(email, password)
.then((session) => {
setSession(session);

account.get().then((user) => {
setLoggedInUser(user);
account
.get()
.then((user) => {
setLoggedInUser(user);

// if sign-in successful, nav to next screen
navigation.navigate("navbar");
});
// if sign-in successful, nav to next screen
navigation.navigate("navbar");
})
.catch((error: any) => {
if (error instanceof Error) {
setErrorMessage(error.message);
setErrorModalVisible(true);
} else {
throw error;
}
});
})
.catch((error: any) => {
if (error instanceof Error) {
setErrorMessage(error.message);
setErrorModalVisible(true);
} else {
throw error;
}
});
} catch (error: any) {
if (error instanceof Error) {
setErrorMessage(error.message);
setErrorModalVisible(true);
} else {
throw error;
}
}
};

return (
Expand Down

0 comments on commit dddf409

Please sign in to comment.