From d833484ac30c3deed9ea3fa0126e5b489e3c9dfb Mon Sep 17 00:00:00 2001 From: Wildan Muhlis Date: Tue, 1 Oct 2024 15:31:30 +0700 Subject: [PATCH 1/8] Fix long loading if login from public page, keep the user on the lastVisitedPath --- src/libs/ReportUtils.ts | 6 ------ .../BaseOnboardingPersonalDetails.tsx | 10 +++++----- src/pages/signin/SignInModal.tsx | 5 ++++- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 71ab125cd367..c6634467bf96 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -1360,12 +1360,6 @@ function findLastAccessedReport(ignoreDomainRooms: boolean, openOnAdminRoom = fa }); } - // if the user hasn't completed the onboarding flow, whether the user should be in the concierge chat or system chat - // should be consistent with what chat the user will land after onboarding flow - if (!getIsSmallScreenWidth() && !Array.isArray(onboarding) && !onboarding?.hasCompletedGuidedSetupFlow) { - return reportsValues.find(isChatUsedForOnboarding); - } - // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing const shouldFilter = excludeReportID || ignoreDomainRooms; if (shouldFilter) { diff --git a/src/pages/OnboardingPersonalDetails/BaseOnboardingPersonalDetails.tsx b/src/pages/OnboardingPersonalDetails/BaseOnboardingPersonalDetails.tsx index 75559aa54803..0e0961a767d8 100644 --- a/src/pages/OnboardingPersonalDetails/BaseOnboardingPersonalDetails.tsx +++ b/src/pages/OnboardingPersonalDetails/BaseOnboardingPersonalDetails.tsx @@ -70,11 +70,11 @@ function BaseOnboardingPersonalDetails({ Navigation.dismissModal(); - // Only navigate to concierge chat when central pane is visible - // Otherwise stay on the chats screen. - if (!shouldUseNarrowLayout && !route.params?.backTo) { - Report.navigateToConciergeChat(); - } + // // Only navigate to concierge chat when central pane is visible + // // Otherwise stay on the chats screen. + // if (!shouldUseNarrowLayout && !route.params?.backTo) { + // Report.navigateToConciergeChat(); + // } }, [onboardingPurposeSelected, onboardingAdminsChatReportID, onboardingPolicyID, shouldUseNarrowLayout, route.params?.backTo], ); diff --git a/src/pages/signin/SignInModal.tsx b/src/pages/signin/SignInModal.tsx index bad93b29f8af..88b26b741ac2 100644 --- a/src/pages/signin/SignInModal.tsx +++ b/src/pages/signin/SignInModal.tsx @@ -13,6 +13,7 @@ import SCREENS from '@src/SCREENS'; import type {Session} from '@src/types/onyx'; import SignInPage from './SignInPage'; import type {SignInPageRef} from './SignInPage'; +import { waitForIdle } from '@libs/Network/SequentialQueue'; type SignInModalOnyxProps = { session: OnyxEntry; @@ -30,7 +31,9 @@ function SignInModal({session}: SignInModalProps) { if (!isAnonymousUser) { // Signing in RHP is only for anonymous users Navigation.isNavigationReady().then(() => Navigation.dismissModal()); - App.openApp(); + waitForIdle().then(() => { + App.openApp(); + }) } }, [session?.authTokenType]); From c4e2a6e72bc3a50e4e17efee6f0ae6682c146b2f Mon Sep 17 00:00:00 2001 From: Wildan Muhlis Date: Fri, 4 Oct 2024 13:54:31 +0700 Subject: [PATCH 2/8] Fix lint and prettier --- src/libs/ReportUtils.ts | 1 - .../BaseOnboardingPersonalDetails.tsx | 12 +++--------- src/pages/signin/SignInModal.tsx | 4 ++-- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index f3030548f6d8..464398bbc55c 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -65,7 +65,6 @@ import * as CurrencyUtils from './CurrencyUtils'; import DateUtils from './DateUtils'; import {hasValidDraftComment} from './DraftCommentUtils'; import getAttachmentDetails from './fileDownload/getAttachmentDetails'; -import getIsSmallScreenWidth from './getIsSmallScreenWidth'; import isReportMessageAttachment from './isReportMessageAttachment'; import localeCompare from './LocaleCompare'; import * as LocalePhoneNumber from './LocalePhoneNumber'; diff --git a/src/pages/OnboardingPersonalDetails/BaseOnboardingPersonalDetails.tsx b/src/pages/OnboardingPersonalDetails/BaseOnboardingPersonalDetails.tsx index f84597dd22cd..6219f91c9117 100644 --- a/src/pages/OnboardingPersonalDetails/BaseOnboardingPersonalDetails.tsx +++ b/src/pages/OnboardingPersonalDetails/BaseOnboardingPersonalDetails.tsx @@ -27,13 +27,13 @@ import ONYXKEYS from '@src/ONYXKEYS'; import INPUT_IDS from '@src/types/form/DisplayNameForm'; import type {BaseOnboardingPersonalDetailsProps} from './types'; -function BaseOnboardingPersonalDetails({currentUserPersonalDetails, shouldUseNativeStyles, route}: BaseOnboardingPersonalDetailsProps) { +function BaseOnboardingPersonalDetails({currentUserPersonalDetails, shouldUseNativeStyles}: BaseOnboardingPersonalDetailsProps) { const styles = useThemeStyles(); const {translate} = useLocalize(); const [onboardingPurposeSelected] = useOnyx(ONYXKEYS.ONBOARDING_PURPOSE_SELECTED); const [onboardingAdminsChatReportID] = useOnyx(ONYXKEYS.ONBOARDING_ADMINS_CHAT_REPORT_ID); const [onboardingPolicyID] = useOnyx(ONYXKEYS.ONBOARDING_POLICY_ID); - const {shouldUseNarrowLayout, isSmallScreenWidth, onboardingIsMediumOrLargerScreenWidth} = useResponsiveLayout(); + const {isSmallScreenWidth, onboardingIsMediumOrLargerScreenWidth} = useResponsiveLayout(); const {inputCallbackRef} = useAutoFocusInput(); const [shouldValidateOnChange, setShouldValidateOnChange] = useState(false); const {isOffline} = useNetwork(); @@ -68,14 +68,8 @@ function BaseOnboardingPersonalDetails({currentUserPersonalDetails, shouldUseNat Welcome.setOnboardingPolicyID(); Navigation.dismissModal(); - - // // Only navigate to concierge chat when central pane is visible - // // Otherwise stay on the chats screen. - // if (!shouldUseNarrowLayout && !route.params?.backTo) { - // Report.navigateToConciergeChat(); - // } }, - [onboardingPurposeSelected, onboardingAdminsChatReportID, onboardingPolicyID, shouldUseNarrowLayout, route.params?.backTo], + [onboardingPurposeSelected, onboardingAdminsChatReportID, onboardingPolicyID], ); const validate = (values: FormOnyxValues<'onboardingPersonalDetailsForm'>) => { diff --git a/src/pages/signin/SignInModal.tsx b/src/pages/signin/SignInModal.tsx index 88b26b741ac2..1ee157234820 100644 --- a/src/pages/signin/SignInModal.tsx +++ b/src/pages/signin/SignInModal.tsx @@ -6,6 +6,7 @@ import ScreenWrapper from '@components/ScreenWrapper'; import useStyleUtils from '@hooks/useStyleUtils'; import useTheme from '@hooks/useTheme'; import Navigation from '@libs/Navigation/Navigation'; +import {waitForIdle} from '@libs/Network/SequentialQueue'; import * as App from '@userActions/App'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; @@ -13,7 +14,6 @@ import SCREENS from '@src/SCREENS'; import type {Session} from '@src/types/onyx'; import SignInPage from './SignInPage'; import type {SignInPageRef} from './SignInPage'; -import { waitForIdle } from '@libs/Network/SequentialQueue'; type SignInModalOnyxProps = { session: OnyxEntry; @@ -33,7 +33,7 @@ function SignInModal({session}: SignInModalProps) { Navigation.isNavigationReady().then(() => Navigation.dismissModal()); waitForIdle().then(() => { App.openApp(); - }) + }); } }, [session?.authTokenType]); From 779cb9e639564aacf0928fb953351cb030a1d042 Mon Sep 17 00:00:00 2001 From: Wildan Muhlis Date: Fri, 4 Oct 2024 13:59:28 +0700 Subject: [PATCH 3/8] replace deprecated withOnyx --- src/pages/signin/SignInModal.tsx | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/src/pages/signin/SignInModal.tsx b/src/pages/signin/SignInModal.tsx index 1ee157234820..d91ad378162a 100644 --- a/src/pages/signin/SignInModal.tsx +++ b/src/pages/signin/SignInModal.tsx @@ -1,7 +1,6 @@ import React, {useEffect, useRef} from 'react'; -import type {OnyxEntry} from 'react-native-onyx'; -import {withOnyx} from 'react-native-onyx'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; +import {useSession} from '@components/OnyxProvider'; import ScreenWrapper from '@components/ScreenWrapper'; import useStyleUtils from '@hooks/useStyleUtils'; import useTheme from '@hooks/useTheme'; @@ -9,22 +8,15 @@ import Navigation from '@libs/Navigation/Navigation'; import {waitForIdle} from '@libs/Network/SequentialQueue'; import * as App from '@userActions/App'; import CONST from '@src/CONST'; -import ONYXKEYS from '@src/ONYXKEYS'; import SCREENS from '@src/SCREENS'; -import type {Session} from '@src/types/onyx'; import SignInPage from './SignInPage'; import type {SignInPageRef} from './SignInPage'; -type SignInModalOnyxProps = { - session: OnyxEntry; -}; - -type SignInModalProps = SignInModalOnyxProps; - -function SignInModal({session}: SignInModalProps) { +function SignInModal() { const theme = useTheme(); const StyleUtils = useStyleUtils(); const siginPageRef = useRef(null); + const session = useSession(); useEffect(() => { const isAnonymousUser = session?.authTokenType === CONST.AUTH_TOKEN_TYPES.ANONYMOUS; @@ -64,6 +56,4 @@ function SignInModal({session}: SignInModalProps) { SignInModal.displayName = 'SignInModal'; -export default withOnyx({ - session: {key: ONYXKEYS.SESSION}, -})(SignInModal); +export default SignInModal; From 9c21e5f0038c7df61a964fb8d8fd5d5804ddb215 Mon Sep 17 00:00:00 2001 From: Wildan Muhlis Date: Fri, 4 Oct 2024 14:03:57 +0700 Subject: [PATCH 4/8] Add comment to openApp --- src/pages/signin/SignInModal.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/pages/signin/SignInModal.tsx b/src/pages/signin/SignInModal.tsx index d91ad378162a..0c8373babae5 100644 --- a/src/pages/signin/SignInModal.tsx +++ b/src/pages/signin/SignInModal.tsx @@ -23,6 +23,10 @@ function SignInModal() { if (!isAnonymousUser) { // Signing in RHP is only for anonymous users Navigation.isNavigationReady().then(() => Navigation.dismissModal()); + + // To prevent deadlock when OpenReport and OpenApp overlap, wait for the queue to be idle before calling openApp. + // This ensures that any communication gaps between the client and server during OpenReport processing do not cause the queue to pause, + // which would prevent us from processing or clearing the queue. waitForIdle().then(() => { App.openApp(); }); From 2c17429394dd40bd623219e8b637a8d506d5c9e5 Mon Sep 17 00:00:00 2001 From: Wildan Muhlis Date: Sat, 5 Oct 2024 07:22:12 +0700 Subject: [PATCH 5/8] Fix redirection in small screen --- .../BaseOnboardingPersonalDetails.tsx | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/pages/OnboardingPersonalDetails/BaseOnboardingPersonalDetails.tsx b/src/pages/OnboardingPersonalDetails/BaseOnboardingPersonalDetails.tsx index 6219f91c9117..9184cf25cc7e 100644 --- a/src/pages/OnboardingPersonalDetails/BaseOnboardingPersonalDetails.tsx +++ b/src/pages/OnboardingPersonalDetails/BaseOnboardingPersonalDetails.tsx @@ -10,13 +10,17 @@ import ScreenWrapper from '@components/ScreenWrapper'; import Text from '@components/Text'; import TextInput from '@components/TextInput'; import withCurrentUserPersonalDetails from '@components/withCurrentUserPersonalDetails'; +import useActiveWorkspace from '@hooks/useActiveWorkspace'; import useAutoFocusInput from '@hooks/useAutoFocusInput'; import useLocalize from '@hooks/useLocalize'; import useNetwork from '@hooks/useNetwork'; +import usePermissions from '@hooks/usePermissions'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useThemeStyles from '@hooks/useThemeStyles'; import * as ErrorUtils from '@libs/ErrorUtils'; +import getCurrentUrl from '@libs/Navigation/currentUrl'; import Navigation from '@libs/Navigation/Navigation'; +import * as ReportUtils from '@libs/ReportUtils'; import * as ValidationUtils from '@libs/ValidationUtils'; import * as PersonalDetails from '@userActions/PersonalDetails'; import * as Report from '@userActions/Report'; @@ -24,10 +28,16 @@ import * as Welcome from '@userActions/Welcome'; import * as OnboardingFlow from '@userActions/Welcome/OnboardingFlow'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; +import ROUTES from '@src/ROUTES'; import INPUT_IDS from '@src/types/form/DisplayNameForm'; import type {BaseOnboardingPersonalDetailsProps} from './types'; -function BaseOnboardingPersonalDetails({currentUserPersonalDetails, shouldUseNativeStyles}: BaseOnboardingPersonalDetailsProps) { +function shouldOpenOnAdminRoom() { + const url = getCurrentUrl(); + return url ? new URL(url).searchParams.get('openOnAdminRoom') === 'true' : false; +} + +function BaseOnboardingPersonalDetails({currentUserPersonalDetails, shouldUseNativeStyles, navi}: BaseOnboardingPersonalDetailsProps) { const styles = useThemeStyles(); const {translate} = useLocalize(); const [onboardingPurposeSelected] = useOnyx(ONYXKEYS.ONBOARDING_PURPOSE_SELECTED); @@ -37,6 +47,8 @@ function BaseOnboardingPersonalDetails({currentUserPersonalDetails, shouldUseNat const {inputCallbackRef} = useAutoFocusInput(); const [shouldValidateOnChange, setShouldValidateOnChange] = useState(false); const {isOffline} = useNetwork(); + const {canUseDefaultRooms} = usePermissions(); + const {activeWorkspaceID} = useActiveWorkspace(); useEffect(() => { Welcome.setOnboardingErrorMessage(''); @@ -68,6 +80,14 @@ function BaseOnboardingPersonalDetails({currentUserPersonalDetails, shouldUseNat Welcome.setOnboardingPolicyID(); Navigation.dismissModal(); + + const lastAccessedReportID = ReportUtils.findLastAccessedReport(!canUseDefaultRooms, shouldOpenOnAdminRoom(), activeWorkspaceID)?.reportID; + + if (!lastAccessedReportID) { + return; + } + const lastAccessedReportRoute = ROUTES.REPORT_WITH_ID.getRoute(lastAccessedReportID ?? '-1'); + Navigation.navigate(lastAccessedReportRoute); }, [onboardingPurposeSelected, onboardingAdminsChatReportID, onboardingPolicyID], ); From e9e104d8bc29133b8932240286f925fb4df83a5d Mon Sep 17 00:00:00 2001 From: Wildan Muhlis Date: Sat, 5 Oct 2024 08:43:05 +0700 Subject: [PATCH 6/8] add isSmallScreenWidth check and comment --- .../BaseOnboardingPersonalDetails.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/pages/OnboardingPersonalDetails/BaseOnboardingPersonalDetails.tsx b/src/pages/OnboardingPersonalDetails/BaseOnboardingPersonalDetails.tsx index 9184cf25cc7e..8c60647a6dd3 100644 --- a/src/pages/OnboardingPersonalDetails/BaseOnboardingPersonalDetails.tsx +++ b/src/pages/OnboardingPersonalDetails/BaseOnboardingPersonalDetails.tsx @@ -81,8 +81,13 @@ function BaseOnboardingPersonalDetails({currentUserPersonalDetails, shouldUseNat Navigation.dismissModal(); + // When hasCompletedGuidedSetupFlow is true, OnboardingModalNavigator in AuthScreen is removed from the navigation stack. + // On small screens, this removal redirects navigation to HOME. Dismissing the modal doesn't work properly, + // so we need to specifically navigate to the last accessed report. + if (!isSmallScreenWidth) { + return; + } const lastAccessedReportID = ReportUtils.findLastAccessedReport(!canUseDefaultRooms, shouldOpenOnAdminRoom(), activeWorkspaceID)?.reportID; - if (!lastAccessedReportID) { return; } From 82f82ff3ee28a81f31a121e0a388e80448638831 Mon Sep 17 00:00:00 2001 From: Wildan Muhlis Date: Sat, 5 Oct 2024 08:51:12 +0700 Subject: [PATCH 7/8] apply DRY to shouldOpenOnAdminRoom, add missing dependency --- src/libs/Navigation/AppNavigator/AuthScreens.tsx | 6 +----- src/libs/Navigation/shouldOpenOnAdminRoom.ts | 6 ++++++ .../BaseOnboardingPersonalDetails.tsx | 11 +++-------- 3 files changed, 10 insertions(+), 13 deletions(-) create mode 100644 src/libs/Navigation/shouldOpenOnAdminRoom.ts diff --git a/src/libs/Navigation/AppNavigator/AuthScreens.tsx b/src/libs/Navigation/AppNavigator/AuthScreens.tsx index f5f35fd21025..c4299f65161c 100644 --- a/src/libs/Navigation/AppNavigator/AuthScreens.tsx +++ b/src/libs/Navigation/AppNavigator/AuthScreens.tsx @@ -22,6 +22,7 @@ import Log from '@libs/Log'; import getCurrentUrl from '@libs/Navigation/currentUrl'; import getOnboardingModalScreenOptions from '@libs/Navigation/getOnboardingModalScreenOptions'; import Navigation from '@libs/Navigation/Navigation'; +import shouldOpenOnAdminRoom from '@libs/Navigation/shouldOpenOnAdminRoom'; import type {AuthScreensParamList, CentralPaneName, CentralPaneScreensParamList} from '@libs/Navigation/types'; import NetworkConnection from '@libs/NetworkConnection'; import onyxSubscribe from '@libs/onyxSubscribe'; @@ -90,11 +91,6 @@ const loadReportAvatar = () => require('../../../pages/Rep const loadReceiptView = () => require('../../../pages/TransactionReceiptPage').default; const loadWorkspaceJoinUser = () => require('@pages/workspace/WorkspaceJoinUserPage').default; -function shouldOpenOnAdminRoom() { - const url = getCurrentUrl(); - return url ? new URL(url).searchParams.get('openOnAdminRoom') === 'true' : false; -} - function getCentralPaneScreenInitialParams(screenName: CentralPaneName, initialReportID?: string): Partial> { if (screenName === SCREENS.SEARCH.CENTRAL_PANE) { // Generate default query string with buildSearchQueryString without argument. diff --git a/src/libs/Navigation/shouldOpenOnAdminRoom.ts b/src/libs/Navigation/shouldOpenOnAdminRoom.ts new file mode 100644 index 000000000000..a593e8c22768 --- /dev/null +++ b/src/libs/Navigation/shouldOpenOnAdminRoom.ts @@ -0,0 +1,6 @@ +import getCurrentUrl from './currentUrl'; + +export default function shouldOpenOnAdminRoom() { + const url = getCurrentUrl(); + return url ? new URL(url).searchParams.get('openOnAdminRoom') === 'true' : false; +} diff --git a/src/pages/OnboardingPersonalDetails/BaseOnboardingPersonalDetails.tsx b/src/pages/OnboardingPersonalDetails/BaseOnboardingPersonalDetails.tsx index 8c60647a6dd3..41f8fa394ed9 100644 --- a/src/pages/OnboardingPersonalDetails/BaseOnboardingPersonalDetails.tsx +++ b/src/pages/OnboardingPersonalDetails/BaseOnboardingPersonalDetails.tsx @@ -18,8 +18,8 @@ import usePermissions from '@hooks/usePermissions'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useThemeStyles from '@hooks/useThemeStyles'; import * as ErrorUtils from '@libs/ErrorUtils'; -import getCurrentUrl from '@libs/Navigation/currentUrl'; import Navigation from '@libs/Navigation/Navigation'; +import shouldOpenOnAdminRoom from '@libs/Navigation/shouldOpenOnAdminRoom'; import * as ReportUtils from '@libs/ReportUtils'; import * as ValidationUtils from '@libs/ValidationUtils'; import * as PersonalDetails from '@userActions/PersonalDetails'; @@ -32,12 +32,7 @@ import ROUTES from '@src/ROUTES'; import INPUT_IDS from '@src/types/form/DisplayNameForm'; import type {BaseOnboardingPersonalDetailsProps} from './types'; -function shouldOpenOnAdminRoom() { - const url = getCurrentUrl(); - return url ? new URL(url).searchParams.get('openOnAdminRoom') === 'true' : false; -} - -function BaseOnboardingPersonalDetails({currentUserPersonalDetails, shouldUseNativeStyles, navi}: BaseOnboardingPersonalDetailsProps) { +function BaseOnboardingPersonalDetails({currentUserPersonalDetails, shouldUseNativeStyles}: BaseOnboardingPersonalDetailsProps) { const styles = useThemeStyles(); const {translate} = useLocalize(); const [onboardingPurposeSelected] = useOnyx(ONYXKEYS.ONBOARDING_PURPOSE_SELECTED); @@ -94,7 +89,7 @@ function BaseOnboardingPersonalDetails({currentUserPersonalDetails, shouldUseNat const lastAccessedReportRoute = ROUTES.REPORT_WITH_ID.getRoute(lastAccessedReportID ?? '-1'); Navigation.navigate(lastAccessedReportRoute); }, - [onboardingPurposeSelected, onboardingAdminsChatReportID, onboardingPolicyID], + [onboardingPurposeSelected, onboardingAdminsChatReportID, onboardingPolicyID, activeWorkspaceID, canUseDefaultRooms, isSmallScreenWidth], ); const validate = (values: FormOnyxValues<'onboardingPersonalDetailsForm'>) => { From bb305c988138f8f75d530c81bbec9a5673787829 Mon Sep 17 00:00:00 2001 From: Wildan Muhlis Date: Sat, 5 Oct 2024 09:47:35 +0700 Subject: [PATCH 8/8] replace deprecated withOnyx in AuthScreen --- .../Navigation/AppNavigator/AuthScreens.tsx | 32 +++++-------------- 1 file changed, 8 insertions(+), 24 deletions(-) diff --git a/src/libs/Navigation/AppNavigator/AuthScreens.tsx b/src/libs/Navigation/AppNavigator/AuthScreens.tsx index c4299f65161c..648bb94bab7c 100644 --- a/src/libs/Navigation/AppNavigator/AuthScreens.tsx +++ b/src/libs/Navigation/AppNavigator/AuthScreens.tsx @@ -1,10 +1,11 @@ import React, {memo, useEffect, useMemo, useRef, useState} from 'react'; import {View} from 'react-native'; import type {OnyxEntry} from 'react-native-onyx'; -import Onyx, {withOnyx} from 'react-native-onyx'; +import Onyx, {useOnyx} from 'react-native-onyx'; import type {ValueOf} from 'type-fest'; import ActiveGuidesEventListener from '@components/ActiveGuidesEventListener'; import ComposeProviders from '@components/ComposeProviders'; +import {useSession} from '@components/OnyxProvider'; import OptionsListContextProvider from '@components/OptionListContextProvider'; import {SearchContextProvider} from '@components/Search/SearchContext'; import SearchRouterModal from '@components/Search/SearchRouter/SearchRouterModal'; @@ -68,17 +69,6 @@ import OnboardingModalNavigator from './Navigators/OnboardingModalNavigator'; import RightModalNavigator from './Navigators/RightModalNavigator'; import WelcomeVideoModalNavigator from './Navigators/WelcomeVideoModalNavigator'; -type AuthScreensProps = { - /** Session of currently logged in user */ - session: OnyxEntry; - - /** The report ID of the last opened public room as anonymous user */ - lastOpenedPublicRoomID: OnyxEntry; - - /** The last Onyx update ID was applied to the client */ - initialLastUpdateIDAppliedToClient: OnyxEntry; -}; - const loadReportAttachments = () => require('../../../pages/home/report/ReportAttachments').default; const loadValidateLoginPage = () => require('../../../pages/ValidateLoginPage').default; const loadLogOutPreviousUserPage = () => require('../../../pages/LogOutPreviousUserPage').default; @@ -222,7 +212,7 @@ const modalScreenListenersWithCancelSearch = { }, }; -function AuthScreens({session, lastOpenedPublicRoomID, initialLastUpdateIDAppliedToClient}: AuthScreensProps) { +function AuthScreens() { const styles = useThemeStyles(); const StyleUtils = useStyleUtils(); const {shouldUseNarrowLayout, onboardingIsMediumOrLargerScreenWidth, isSmallScreenWidth} = useResponsiveLayout(); @@ -239,6 +229,10 @@ function AuthScreens({session, lastOpenedPublicRoomID, initialLastUpdateIDApplie const {isOnboardingCompleted} = useOnboardingFlowRouter(); let initialReportID: string | undefined; const isInitialRender = useRef(true); + const session = useSession(); + const [lastOpenedPublicRoomID] = useOnyx(ONYXKEYS.LAST_OPENED_PUBLIC_ROOM_ID); + const [initialLastUpdateIDAppliedToClient] = useOnyx(ONYXKEYS.ONYX_UPDATES_LAST_UPDATE_ID_APPLIED_TO_CLIENT); + if (isInitialRender.current) { Timing.start(CONST.TIMING.HOMEPAGE_INITIAL_RENDER); @@ -598,14 +592,4 @@ AuthScreens.displayName = 'AuthScreens'; const AuthScreensMemoized = memo(AuthScreens, () => true); -export default withOnyx({ - session: { - key: ONYXKEYS.SESSION, - }, - lastOpenedPublicRoomID: { - key: ONYXKEYS.LAST_OPENED_PUBLIC_ROOM_ID, - }, - initialLastUpdateIDAppliedToClient: { - key: ONYXKEYS.ONYX_UPDATES_LAST_UPDATE_ID_APPLIED_TO_CLIENT, - }, -})(AuthScreensMemoized); +export default AuthScreensMemoized;