From 01cf8eb0e8879768619ea7fbfd9b3cd555ecda49 Mon Sep 17 00:00:00 2001 From: Carlos Miceli Date: Fri, 25 Oct 2024 00:55:56 -0300 Subject: [PATCH 1/4] add check to wait to show session expired --- src/pages/LogInWithShortLivedAuthTokenPage.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/pages/LogInWithShortLivedAuthTokenPage.tsx b/src/pages/LogInWithShortLivedAuthTokenPage.tsx index fcbeadaa4a47..8eebb8c1ddcd 100644 --- a/src/pages/LogInWithShortLivedAuthTokenPage.tsx +++ b/src/pages/LogInWithShortLivedAuthTokenPage.tsx @@ -1,5 +1,5 @@ import type {StackScreenProps} from '@react-navigation/stack'; -import React, {useEffect} from 'react'; +import React, {useState, useEffect} from 'react'; import {NativeModules} from 'react-native'; import type {OnyxEntry} from 'react-native-onyx'; import {withOnyx} from 'react-native-onyx'; @@ -26,6 +26,9 @@ type LogInWithShortLivedAuthTokenPageProps = LogInWithShortLivedAuthTokenPageOny function LogInWithShortLivedAuthTokenPage({route, account}: LogInWithShortLivedAuthTokenPageProps) { const {email = '', shortLivedAuthToken = '', shortLivedToken = '', authTokenType, exitTo, error} = route?.params ?? {}; + // State to track if authentication flow is still processing + const [isProcessing, setIsProcessing] = useState(true); + useEffect(() => { // We have to check for both shortLivedAuthToken and shortLivedToken, as the old mobile app uses shortLivedToken, and is not being actively updated. const token = shortLivedAuthToken || shortLivedToken; @@ -58,11 +61,13 @@ function LogInWithShortLivedAuthTokenPage({route, account}: LogInWithShortLivedA Navigation.navigate(exitTo as Route); }); } + + setIsProcessing(false); // The only dependencies of the effect are based on props.route // eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps }, [route]); - if (account?.isLoading) { + if (isProcessing || account?.isLoading) { return ; } From 4610ac1743752748072c405b4c8ed1c3e227583f Mon Sep 17 00:00:00 2001 From: Carlos Miceli Date: Fri, 25 Oct 2024 14:13:03 -0300 Subject: [PATCH 2/4] ran prettier --- src/pages/LogInWithShortLivedAuthTokenPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/LogInWithShortLivedAuthTokenPage.tsx b/src/pages/LogInWithShortLivedAuthTokenPage.tsx index 8eebb8c1ddcd..ec245f87aa06 100644 --- a/src/pages/LogInWithShortLivedAuthTokenPage.tsx +++ b/src/pages/LogInWithShortLivedAuthTokenPage.tsx @@ -1,5 +1,5 @@ import type {StackScreenProps} from '@react-navigation/stack'; -import React, {useState, useEffect} from 'react'; +import React, {useEffect, useState} from 'react'; import {NativeModules} from 'react-native'; import type {OnyxEntry} from 'react-native-onyx'; import {withOnyx} from 'react-native-onyx'; From f943b4a9eda7e5c6326d6ca8223bf8eb6b78b8b6 Mon Sep 17 00:00:00 2001 From: Carlos Miceli Date: Fri, 25 Oct 2024 14:56:13 -0300 Subject: [PATCH 3/4] fix eslint --- src/pages/LogInWithShortLivedAuthTokenPage.tsx | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/pages/LogInWithShortLivedAuthTokenPage.tsx b/src/pages/LogInWithShortLivedAuthTokenPage.tsx index ec245f87aa06..8557b45726d9 100644 --- a/src/pages/LogInWithShortLivedAuthTokenPage.tsx +++ b/src/pages/LogInWithShortLivedAuthTokenPage.tsx @@ -1,8 +1,8 @@ import type {StackScreenProps} from '@react-navigation/stack'; -import React, {useEffect, useState} from 'react'; +import React, {useEffect} from 'react'; import {NativeModules} from 'react-native'; import type {OnyxEntry} from 'react-native-onyx'; -import {withOnyx} from 'react-native-onyx'; +import {useOnyx} from 'react-native-onyx'; import FullScreenLoadingIndicator from '@components/FullscreenLoadingIndicator'; import Log from '@libs/Log'; import Navigation from '@libs/Navigation/Navigation'; @@ -23,11 +23,9 @@ type LogInWithShortLivedAuthTokenPageOnyxProps = { type LogInWithShortLivedAuthTokenPageProps = LogInWithShortLivedAuthTokenPageOnyxProps & StackScreenProps; -function LogInWithShortLivedAuthTokenPage({route, account}: LogInWithShortLivedAuthTokenPageProps) { +function LogInWithShortLivedAuthTokenPage({route}: LogInWithShortLivedAuthTokenPageProps) { const {email = '', shortLivedAuthToken = '', shortLivedToken = '', authTokenType, exitTo, error} = route?.params ?? {}; - - // State to track if authentication flow is still processing - const [isProcessing, setIsProcessing] = useState(true); + const [account] = useOnyx(ONYXKEYS.ACCOUNT); useEffect(() => { // We have to check for both shortLivedAuthToken and shortLivedToken, as the old mobile app uses shortLivedToken, and is not being actively updated. @@ -62,12 +60,11 @@ function LogInWithShortLivedAuthTokenPage({route, account}: LogInWithShortLivedA }); } - setIsProcessing(false); // The only dependencies of the effect are based on props.route // eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps }, [route]); - if (isProcessing || account?.isLoading) { + if (account?.isLoading) { return ; } @@ -76,6 +73,4 @@ function LogInWithShortLivedAuthTokenPage({route, account}: LogInWithShortLivedA LogInWithShortLivedAuthTokenPage.displayName = 'LogInWithShortLivedAuthTokenPage'; -export default withOnyx({ - account: {key: ONYXKEYS.ACCOUNT}, -})(LogInWithShortLivedAuthTokenPage); +export default LogInWithShortLivedAuthTokenPage; From ff28dd9f82fbb47ba3fda9ff894a7423718b28fe Mon Sep 17 00:00:00 2001 From: Carlos Miceli Date: Fri, 25 Oct 2024 15:05:38 -0300 Subject: [PATCH 4/4] code cleanup --- src/pages/LogInWithShortLivedAuthTokenPage.tsx | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/pages/LogInWithShortLivedAuthTokenPage.tsx b/src/pages/LogInWithShortLivedAuthTokenPage.tsx index 8557b45726d9..e604f2ccf847 100644 --- a/src/pages/LogInWithShortLivedAuthTokenPage.tsx +++ b/src/pages/LogInWithShortLivedAuthTokenPage.tsx @@ -1,7 +1,6 @@ import type {StackScreenProps} from '@react-navigation/stack'; import React, {useEffect} from 'react'; import {NativeModules} from 'react-native'; -import type {OnyxEntry} from 'react-native-onyx'; import {useOnyx} from 'react-native-onyx'; import FullScreenLoadingIndicator from '@components/FullscreenLoadingIndicator'; import Log from '@libs/Log'; @@ -13,15 +12,9 @@ import ONYXKEYS from '@src/ONYXKEYS'; import type {Route} from '@src/ROUTES'; import ROUTES from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; -import type {Account} from '@src/types/onyx'; import SessionExpiredPage from './ErrorPage/SessionExpiredPage'; -type LogInWithShortLivedAuthTokenPageOnyxProps = { - /** The details about the account that the user is signing in with */ - account: OnyxEntry; -}; - -type LogInWithShortLivedAuthTokenPageProps = LogInWithShortLivedAuthTokenPageOnyxProps & StackScreenProps; +type LogInWithShortLivedAuthTokenPageProps = StackScreenProps; function LogInWithShortLivedAuthTokenPage({route}: LogInWithShortLivedAuthTokenPageProps) { const {email = '', shortLivedAuthToken = '', shortLivedToken = '', authTokenType, exitTo, error} = route?.params ?? {}; @@ -59,7 +52,6 @@ function LogInWithShortLivedAuthTokenPage({route}: LogInWithShortLivedAuthTokenP Navigation.navigate(exitTo as Route); }); } - // The only dependencies of the effect are based on props.route // eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps }, [route]);