Loading mobile/src/auth/contexts/auth_context.tsx +8 −4 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ import { } from "react"; import { UserInfoEntity } from "../domain/entities/user_info_entity"; import * as SecureStore from "expo-secure-store"; import AsyncStorage from "@react-native-async-storage/async-storage"; import axios from "axios"; import { UserPreferences } from "../../common/domain/entities/user_preferences"; Loading Loading @@ -43,7 +44,7 @@ export const AuthContextProvider = ({ children }: AuthContextProviderProps) => { const recoveredUser = JSON.parse(user) as UserInfoEntity; setUser(recoveredUser); const ssKey = recoveredUser.email.split("@")[0]; const userPreferences = SecureStore.getItem(ssKey); const userPreferences = await AsyncStorage.getItem(ssKey); if (userPreferences) { const parsedUserPreferences = JSON.parse( userPreferences Loading @@ -54,7 +55,10 @@ export const AuthContextProvider = ({ children }: AuthContextProviderProps) => { isFirstTime: true, isVerifiedEmail: false, }; SecureStore.setItem(ssKey, JSON.stringify(emptyUserPreferences)); await AsyncStorage.setItem( ssKey, JSON.stringify(emptyUserPreferences) ); setIsVerified(false); } axios.defaults.headers.common["Authorization"] = `Bearer ${token}`; Loading @@ -70,12 +74,12 @@ export const AuthContextProvider = ({ children }: AuthContextProviderProps) => { const verify = async () => { if (!user) return; const sskey = user.email.split("@")[0]; const userPreferences = SecureStore.getItem(sskey); const userPreferences = await AsyncStorage.getItem(sskey); if (!userPreferences) return; const parsedUserPreferences = JSON.parse( userPreferences ) as UserPreferences; SecureStore.setItem( await AsyncStorage.setItem( sskey, JSON.stringify({ ...parsedUserPreferences, isVerifiedEmail: true }) ); Loading mobile/src/common/contexts/set_up_context.tsx +8 −4 Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ import { import * as SecureStore from "expo-secure-store"; import { useAuth } from "../../auth/contexts/auth_context"; import { UserPreferences } from "../domain/entities/user_preferences"; import AsyncStorage from "@react-native-async-storage/async-storage"; type SetUpContextType = { isLoading: boolean; Loading Loading @@ -36,13 +37,13 @@ export const SetUpContextProvider = ({ return; } const sskey = user.email.split("@")[0]; const userPreferences = SecureStore.getItem(sskey); const userPreferences = await AsyncStorage.getItem(sskey); if (userPreferences) { const parsedUserPreferences = JSON.parse( userPreferences ) as UserPreferences; parsedUserPreferences.isFirstTime = false; SecureStore.setItem(sskey, JSON.stringify(parsedUserPreferences)); await AsyncStorage.setItem(sskey, JSON.stringify(parsedUserPreferences)); setIsFirstTime(false); } setIsLoading(false); Loading @@ -63,7 +64,7 @@ export const SetUpContextProvider = ({ return; } const sskey = user.email.split("@")[0]; const value = SecureStore.getItem(sskey); const value = await AsyncStorage.getItem(sskey); if (value) { const userPreferences = JSON.parse(value) as UserPreferences; setIsFirstTime(userPreferences.isFirstTime); Loading @@ -72,7 +73,10 @@ export const SetUpContextProvider = ({ isFirstTime: true, isVerifiedEmail: false, }; SecureStore.setItem(sskey, JSON.stringify(emptyUserPreferences)); await AsyncStorage.setItem( sskey, JSON.stringify(emptyUserPreferences) ); } } catch { console.log("Error checking session"); Loading Loading
mobile/src/auth/contexts/auth_context.tsx +8 −4 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ import { } from "react"; import { UserInfoEntity } from "../domain/entities/user_info_entity"; import * as SecureStore from "expo-secure-store"; import AsyncStorage from "@react-native-async-storage/async-storage"; import axios from "axios"; import { UserPreferences } from "../../common/domain/entities/user_preferences"; Loading Loading @@ -43,7 +44,7 @@ export const AuthContextProvider = ({ children }: AuthContextProviderProps) => { const recoveredUser = JSON.parse(user) as UserInfoEntity; setUser(recoveredUser); const ssKey = recoveredUser.email.split("@")[0]; const userPreferences = SecureStore.getItem(ssKey); const userPreferences = await AsyncStorage.getItem(ssKey); if (userPreferences) { const parsedUserPreferences = JSON.parse( userPreferences Loading @@ -54,7 +55,10 @@ export const AuthContextProvider = ({ children }: AuthContextProviderProps) => { isFirstTime: true, isVerifiedEmail: false, }; SecureStore.setItem(ssKey, JSON.stringify(emptyUserPreferences)); await AsyncStorage.setItem( ssKey, JSON.stringify(emptyUserPreferences) ); setIsVerified(false); } axios.defaults.headers.common["Authorization"] = `Bearer ${token}`; Loading @@ -70,12 +74,12 @@ export const AuthContextProvider = ({ children }: AuthContextProviderProps) => { const verify = async () => { if (!user) return; const sskey = user.email.split("@")[0]; const userPreferences = SecureStore.getItem(sskey); const userPreferences = await AsyncStorage.getItem(sskey); if (!userPreferences) return; const parsedUserPreferences = JSON.parse( userPreferences ) as UserPreferences; SecureStore.setItem( await AsyncStorage.setItem( sskey, JSON.stringify({ ...parsedUserPreferences, isVerifiedEmail: true }) ); Loading
mobile/src/common/contexts/set_up_context.tsx +8 −4 Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ import { import * as SecureStore from "expo-secure-store"; import { useAuth } from "../../auth/contexts/auth_context"; import { UserPreferences } from "../domain/entities/user_preferences"; import AsyncStorage from "@react-native-async-storage/async-storage"; type SetUpContextType = { isLoading: boolean; Loading Loading @@ -36,13 +37,13 @@ export const SetUpContextProvider = ({ return; } const sskey = user.email.split("@")[0]; const userPreferences = SecureStore.getItem(sskey); const userPreferences = await AsyncStorage.getItem(sskey); if (userPreferences) { const parsedUserPreferences = JSON.parse( userPreferences ) as UserPreferences; parsedUserPreferences.isFirstTime = false; SecureStore.setItem(sskey, JSON.stringify(parsedUserPreferences)); await AsyncStorage.setItem(sskey, JSON.stringify(parsedUserPreferences)); setIsFirstTime(false); } setIsLoading(false); Loading @@ -63,7 +64,7 @@ export const SetUpContextProvider = ({ return; } const sskey = user.email.split("@")[0]; const value = SecureStore.getItem(sskey); const value = await AsyncStorage.getItem(sskey); if (value) { const userPreferences = JSON.parse(value) as UserPreferences; setIsFirstTime(userPreferences.isFirstTime); Loading @@ -72,7 +73,10 @@ export const SetUpContextProvider = ({ isFirstTime: true, isVerifiedEmail: false, }; SecureStore.setItem(sskey, JSON.stringify(emptyUserPreferences)); await AsyncStorage.setItem( sskey, JSON.stringify(emptyUserPreferences) ); } } catch { console.log("Error checking session"); Loading