diff --git a/mobile/Components/ProfileTabs/ProfileTabs.tsx b/mobile/Components/ProfileTabs/ProfileTabs.tsx index a483008d..dfb8e6a4 100644 --- a/mobile/Components/ProfileTabs/ProfileTabs.tsx +++ b/mobile/Components/ProfileTabs/ProfileTabs.tsx @@ -82,7 +82,7 @@ function MyTabBar({ state, descriptors, navigation, position }) { } function ProfileTab(props) { - const { setLoggedIn } = React.useContext(LoginStateContext)!; + const { refreshLoginState } = React.useContext(LoginStateContext)!; const { navigation } = React.useContext(ProfileContext); const account = new Account(client); const navigateDeleteAccount = () => { @@ -105,7 +105,7 @@ function ProfileTab(props) { } catch (error) { console.log(error); } - setLoggedIn(false); + refreshLoginState(); } return ( diff --git a/mobile/Providers/LoginStateProvider.tsx b/mobile/Providers/LoginStateProvider.tsx index 477e93f8..a59a4ab4 100644 --- a/mobile/Providers/LoginStateProvider.tsx +++ b/mobile/Providers/LoginStateProvider.tsx @@ -7,7 +7,6 @@ const account = new Account(client); export interface LoginStateContextType { loggedIn: boolean | null; - setLoggedIn: React.Dispatch>; refreshLoginState: () => void; } @@ -39,9 +38,7 @@ function LoginStateProvider({ children }: { children: React.ReactNode }) { }, []); return ( - + {children} ); diff --git a/mobile/Screens/CreateAccount.tsx b/mobile/Screens/CreateAccount.tsx index c8bccb48..6e0f2a39 100644 --- a/mobile/Screens/CreateAccount.tsx +++ b/mobile/Screens/CreateAccount.tsx @@ -34,7 +34,7 @@ export const CreateAccount = (props) => { const [errorModalVisible, setErrorModalVisible] = React.useState(false); const [errorMessage, setErrorMessage] = React.useState(""); const [loading, setLoading] = React.useState(false); - const { setLoggedIn } = React.useContext(LoginStateContext); + const { refreshLoginState } = React.useContext(LoginStateContext)!; const handleSwitch = () => { navigation.navigate("sign_in"); @@ -91,7 +91,7 @@ export const CreateAccount = (props) => { const response = await account.create(ID.unique(), email, password, name); await account.createEmailPasswordSession(email, password); const userResponse = await account.get(); - setLoggedIn(true); + refreshLoginState(); const check = await registerIndieID( userResponse.$id, 20878, diff --git a/mobile/Screens/DeleteAccount.tsx b/mobile/Screens/DeleteAccount.tsx index 62a7698a..4cd950cb 100644 --- a/mobile/Screens/DeleteAccount.tsx +++ b/mobile/Screens/DeleteAccount.tsx @@ -13,8 +13,7 @@ import Toast from "react-native-toast-message"; const account = new Account(client); function DeleteAccount() { - const { loggedIn, setLoggedIn, refreshLoginState } = - React.useContext(LoginStateContext); + const { loggedIn, refreshLoginState } = React.useContext(LoginStateContext)!; const [confirmed, setConfirmed] = React.useState(false); const [deleting, setDeleting] = React.useState(false); @@ -46,7 +45,7 @@ function DeleteAccount() { if (res.ok) { account.deleteSessions(); - setLoggedIn(false); + refreshLoginState(); Toast.show({ type: "success", text1: "Your account was successfully deleted! See you again soon!", diff --git a/mobile/Screens/SignIn.tsx b/mobile/Screens/SignIn.tsx index 5f5ab78d..984304b0 100644 --- a/mobile/Screens/SignIn.tsx +++ b/mobile/Screens/SignIn.tsx @@ -34,7 +34,7 @@ export const SignIn = ({ navigation }: Props) => { const [errorModalVisible, setErrorModalVisible] = React.useState(false); const [errorMessage, setErrorMessage] = React.useState(""); const [loading, setLoading] = React.useState(false); - const { setLoggedIn } = React.useContext(LoginStateContext)!; + const { refreshLoginState } = React.useContext(LoginStateContext)!; const handleCreateAccount = () => { navigation.navigate("create_account"); @@ -48,7 +48,7 @@ export const SignIn = ({ navigation }: Props) => { try { await account.createEmailPasswordSession(email, password); const account_res = await account.get(); - setLoggedIn(true); + refreshLoginState(); const yep = await registerIndieID(account_res.$id, 20878, 'sMBFDEdTPOzXb6A2bqP169'); console.log(yep); } catch (error) {