From 8b947e3d8d91af218e9d8532c171bd283ecd85f8 Mon Sep 17 00:00:00 2001 From: Hezekiel Tamire <39636266+HezekielT@users.noreply.github.com> Date: Thu, 8 Aug 2024 21:15:21 +0300 Subject: [PATCH] Revert "Fix - no abracadabra page shown" --- .../Navigation/AppNavigator/AuthScreens.tsx | 31 +++++++++++++++---- src/pages/ValidateLoginPage/index.website.tsx | 14 ++++++--- 2 files changed, 34 insertions(+), 11 deletions(-) diff --git a/src/libs/Navigation/AppNavigator/AuthScreens.tsx b/src/libs/Navigation/AppNavigator/AuthScreens.tsx index 64816562a507..071b6d8270d7 100644 --- a/src/libs/Navigation/AppNavigator/AuthScreens.tsx +++ b/src/libs/Navigation/AppNavigator/AuthScreens.tsx @@ -1,7 +1,7 @@ import React, {memo, useEffect, useMemo, useRef} from 'react'; import {View} from 'react-native'; import type {OnyxEntry} from 'react-native-onyx'; -import Onyx, {useOnyx} from 'react-native-onyx'; +import Onyx, {withOnyx} from 'react-native-onyx'; import type {ValueOf} from 'type-fest'; import OptionsListContextProvider from '@components/OptionListContextProvider'; import useActiveWorkspace from '@hooks/useActiveWorkspace'; @@ -44,6 +44,7 @@ import NAVIGATORS from '@src/NAVIGATORS'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import SCREENS from '@src/SCREENS'; +import type * as OnyxTypes from '@src/types/onyx'; import type {SelectedTimezone, Timezone} from '@src/types/onyx/PersonalDetails'; import type ReactComponentModule from '@src/types/utils/ReactComponentModule'; import CENTRAL_PANE_SCREENS from './CENTRAL_PANE_SCREENS'; @@ -59,6 +60,17 @@ 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; @@ -190,14 +202,11 @@ const modalScreenListenersWithCancelSearch = { }, }; -function AuthScreens() { +function AuthScreens({session, lastOpenedPublicRoomID, initialLastUpdateIDAppliedToClient}: AuthScreensProps) { const styles = useThemeStyles(); const StyleUtils = useStyleUtils(); const {isSmallScreenWidth} = useWindowDimensions(); const {isMediumOrLargerScreenWidth} = useOnboardingLayout(); - const [session] = useOnyx(ONYXKEYS.SESSION); - const [lastOpenedPublicRoomID] = useOnyx(ONYXKEYS.LAST_OPENED_PUBLIC_ROOM_ID); - const [initialLastUpdateIDAppliedToClient] = useOnyx(ONYXKEYS.ONYX_UPDATES_LAST_UPDATE_ID_APPLIED_TO_CLIENT); const screenOptions = getRootNavigatorScreenOptions(isSmallScreenWidth, styles, StyleUtils); const {canUseDefaultRooms} = usePermissions(); const {activeWorkspaceID} = useActiveWorkspace(); @@ -513,4 +522,14 @@ AuthScreens.displayName = 'AuthScreens'; const AuthScreensMemoized = memo(AuthScreens, () => true); -export default AuthScreensMemoized; +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); diff --git a/src/pages/ValidateLoginPage/index.website.tsx b/src/pages/ValidateLoginPage/index.website.tsx index b7d46b88faaa..13f636867852 100644 --- a/src/pages/ValidateLoginPage/index.website.tsx +++ b/src/pages/ValidateLoginPage/index.website.tsx @@ -1,5 +1,5 @@ import React, {useEffect} from 'react'; -import {useOnyx} from 'react-native-onyx'; +import {withOnyx} from 'react-native-onyx'; import FullScreenLoadingIndicator from '@components/FullscreenLoadingIndicator'; import ExpiredValidateCodeModal from '@components/ValidateCode/ExpiredValidateCodeModal'; import JustSignedInModal from '@components/ValidateCode/JustSignedInModal'; @@ -12,13 +12,13 @@ import ONYXKEYS from '@src/ONYXKEYS'; import type {ValidateLoginPageOnyxProps, ValidateLoginPageProps} from './types'; function ValidateLoginPage({ + account, + credentials, route: { params: {accountID, validateCode, exitTo}, }, + session, }: ValidateLoginPageProps) { - const [session] = useOnyx(ONYXKEYS.SESSION); - const [credentials] = useOnyx(ONYXKEYS.CREDENTIALS); - const [account] = useOnyx(ONYXKEYS.ACCOUNT); const login = credentials?.login; const autoAuthState = session?.autoAuthState ?? CONST.AUTO_AUTH_STATE.NOT_STARTED; const isSignedIn = !!session?.authToken && session?.authTokenType !== CONST.AUTH_TOKEN_TYPES.ANONYMOUS; @@ -87,4 +87,8 @@ function ValidateLoginPage({ ValidateLoginPage.displayName = 'ValidateLoginPage'; -export default ValidateLoginPage; +export default withOnyx, ValidateLoginPageOnyxProps>({ + account: {key: ONYXKEYS.ACCOUNT}, + credentials: {key: ONYXKEYS.CREDENTIALS}, + session: {key: ONYXKEYS.SESSION}, +})(ValidateLoginPage);