From 54ab17ef51d501217bf2cc17f65ff7e0062291b4 Mon Sep 17 00:00:00 2001 From: BhuvaneshPatil Date: Wed, 13 Nov 2024 00:04:55 +0530 Subject: [PATCH 1/4] chore: migrate authscreens --- .../Navigation/AppNavigator/AuthScreens.tsx | 43 +++++++++++++------ 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/src/libs/Navigation/AppNavigator/AuthScreens.tsx b/src/libs/Navigation/AppNavigator/AuthScreens.tsx index 58586250f958..abcbd3de31fb 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, 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'; @@ -68,6 +68,8 @@ import LeftModalNavigator from './Navigators/LeftModalNavigator'; import OnboardingModalNavigator from './Navigators/OnboardingModalNavigator'; import RightModalNavigator from './Navigators/RightModalNavigator'; import WelcomeVideoModalNavigator from './Navigators/WelcomeVideoModalNavigator'; +import isLoadingOnyxValue from '@src/types/utils/isLoadingOnyxValue'; +import FullScreenLoadingIndicator from '@components/FullscreenLoadingIndicator'; type AuthScreensProps = { /** Session of currently logged in user */ @@ -601,18 +603,35 @@ AuthScreens.displayName = 'AuthScreens'; const AuthScreensMemoized = memo(AuthScreens, () => true); +export default function AuthScreensWithOnyx() { + const [session, sessionStatus] = useOnyx(ONYXKEYS.SESSION); + const [lastOpenedPublicRoomID, lastOpenedPublicRoomIDStatus] = useOnyx(ONYXKEYS.LAST_OPENED_PUBLIC_ROOM_ID); + const [initialLastUpdateIDAppliedToClient, initialLastUpdateIDAppliedToClientStatus] = useOnyx(ONYXKEYS.ONYX_UPDATES_LAST_UPDATE_ID_APPLIED_TO_CLIENT); + + if (isLoadingOnyxValue(sessionStatus, lastOpenedPublicRoomIDStatus, initialLastUpdateIDAppliedToClientStatus)) { + return ; + } + + return ( + + ); + } // Migration to useOnyx cause re-login if logout from deeplinked report in desktop app // Further analysis required and more details can be seen here: // https://github.com/Expensify/App/issues/50560 // eslint-disable-next-line -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 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); From 574a614c4b1ab7b4968966e37434cd7513a26810 Mon Sep 17 00:00:00 2001 From: BhuvaneshPatil Date: Wed, 13 Nov 2024 00:12:31 +0530 Subject: [PATCH 2/4] remove comments --- .../Navigation/AppNavigator/AuthScreens.tsx | 51 ++++++++----------- 1 file changed, 20 insertions(+), 31 deletions(-) diff --git a/src/libs/Navigation/AppNavigator/AuthScreens.tsx b/src/libs/Navigation/AppNavigator/AuthScreens.tsx index abcbd3de31fb..64d6b7377876 100644 --- a/src/libs/Navigation/AppNavigator/AuthScreens.tsx +++ b/src/libs/Navigation/AppNavigator/AuthScreens.tsx @@ -5,6 +5,7 @@ import Onyx, {useOnyx} from 'react-native-onyx'; import type {ValueOf} from 'type-fest'; import ActiveGuidesEventListener from '@components/ActiveGuidesEventListener'; import ComposeProviders from '@components/ComposeProviders'; +import FullScreenLoadingIndicator from '@components/FullscreenLoadingIndicator'; import OptionsListContextProvider from '@components/OptionListContextProvider'; import {SearchContextProvider} from '@components/Search/SearchContext'; import {useSearchRouterContext} from '@components/Search/SearchRouter/SearchRouterContext'; @@ -54,6 +55,7 @@ import SCREENS from '@src/SCREENS'; import type * as OnyxTypes from '@src/types/onyx'; import type {SelectedTimezone, Timezone} from '@src/types/onyx/PersonalDetails'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; +import isLoadingOnyxValue from '@src/types/utils/isLoadingOnyxValue'; import type ReactComponentModule from '@src/types/utils/ReactComponentModule'; import beforeRemoveReportOpenedFromSearchRHP from './beforeRemoveReportOpenedFromSearchRHP'; import CENTRAL_PANE_SCREENS from './CENTRAL_PANE_SCREENS'; @@ -68,8 +70,6 @@ import LeftModalNavigator from './Navigators/LeftModalNavigator'; import OnboardingModalNavigator from './Navigators/OnboardingModalNavigator'; import RightModalNavigator from './Navigators/RightModalNavigator'; import WelcomeVideoModalNavigator from './Navigators/WelcomeVideoModalNavigator'; -import isLoadingOnyxValue from '@src/types/utils/isLoadingOnyxValue'; -import FullScreenLoadingIndicator from '@components/FullscreenLoadingIndicator'; type AuthScreensProps = { /** Session of currently logged in user */ @@ -603,35 +603,24 @@ AuthScreens.displayName = 'AuthScreens'; const AuthScreensMemoized = memo(AuthScreens, () => true); -export default function AuthScreensWithOnyx() { - const [session, sessionStatus] = useOnyx(ONYXKEYS.SESSION); - const [lastOpenedPublicRoomID, lastOpenedPublicRoomIDStatus] = useOnyx(ONYXKEYS.LAST_OPENED_PUBLIC_ROOM_ID); - const [initialLastUpdateIDAppliedToClient, initialLastUpdateIDAppliedToClientStatus] = useOnyx(ONYXKEYS.ONYX_UPDATES_LAST_UPDATE_ID_APPLIED_TO_CLIENT); - - if (isLoadingOnyxValue(sessionStatus, lastOpenedPublicRoomIDStatus, initialLastUpdateIDAppliedToClientStatus)) { - return ; - } - - return ( - - ); - } // Migration to useOnyx cause re-login if logout from deeplinked report in desktop app // Further analysis required and more details can be seen here: // https://github.com/Expensify/App/issues/50560 -// eslint-disable-next-line -// 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 function AuthScreensWithOnyx() { + const [session, sessionStatus] = useOnyx(ONYXKEYS.SESSION); + const [lastOpenedPublicRoomID, lastOpenedPublicRoomIDStatus] = useOnyx(ONYXKEYS.LAST_OPENED_PUBLIC_ROOM_ID); + const [initialLastUpdateIDAppliedToClient, initialLastUpdateIDAppliedToClientStatus] = useOnyx(ONYXKEYS.ONYX_UPDATES_LAST_UPDATE_ID_APPLIED_TO_CLIENT); + + if (isLoadingOnyxValue(sessionStatus, lastOpenedPublicRoomIDStatus, initialLastUpdateIDAppliedToClientStatus)) { + return ; + } + + return ( + + ); +} + From 7cb691f8a6c3e6458f87b8a5102ac73b07252a3c Mon Sep 17 00:00:00 2001 From: BhuvaneshPatil Date: Wed, 13 Nov 2024 18:44:59 +0530 Subject: [PATCH 3/4] fixed lint --- src/libs/Navigation/AppNavigator/AuthScreens.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libs/Navigation/AppNavigator/AuthScreens.tsx b/src/libs/Navigation/AppNavigator/AuthScreens.tsx index 64d6b7377876..559ae64208af 100644 --- a/src/libs/Navigation/AppNavigator/AuthScreens.tsx +++ b/src/libs/Navigation/AppNavigator/AuthScreens.tsx @@ -623,4 +623,3 @@ export default function AuthScreensWithOnyx() { /> ); } - From 4472283625692a697a583a4e3c3c389c02cdc8de Mon Sep 17 00:00:00 2001 From: Bhuvanesh Date: Sat, 16 Nov 2024 21:23:33 +0530 Subject: [PATCH 4/4] Update src/libs/Navigation/AppNavigator/AuthScreens.tsx MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Błażej Kustra <46095609+blazejkustra@users.noreply.github.com> --- src/libs/Navigation/AppNavigator/AuthScreens.tsx | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/libs/Navigation/AppNavigator/AuthScreens.tsx b/src/libs/Navigation/AppNavigator/AuthScreens.tsx index 559ae64208af..7bc061650662 100644 --- a/src/libs/Navigation/AppNavigator/AuthScreens.tsx +++ b/src/libs/Navigation/AppNavigator/AuthScreens.tsx @@ -603,9 +603,6 @@ AuthScreens.displayName = 'AuthScreens'; const AuthScreensMemoized = memo(AuthScreens, () => true); -// Migration to useOnyx cause re-login if logout from deeplinked report in desktop app -// Further analysis required and more details can be seen here: -// https://github.com/Expensify/App/issues/50560 export default function AuthScreensWithOnyx() { const [session, sessionStatus] = useOnyx(ONYXKEYS.SESSION); const [lastOpenedPublicRoomID, lastOpenedPublicRoomIDStatus] = useOnyx(ONYXKEYS.LAST_OPENED_PUBLIC_ROOM_ID);