Skip to content

Commit 7772c38

Browse files
authored
Merge pull request Expensify#49922 from Expensify/revert-49185-49103-onyx-migration
Revert "chore: migrate AuthScreens from withOnyx to useOnyx"
2 parents 5aba99c + 32f1066 commit 7772c38

File tree

3 files changed

+26
-18
lines changed

3 files changed

+26
-18
lines changed

src/libs/Navigation/AppNavigator/AuthScreens.tsx

+26-10
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, {memo, useEffect, useMemo, useRef, useState} from 'react';
22
import {View} from 'react-native';
33
import type {OnyxEntry} from 'react-native-onyx';
4-
import Onyx, {useOnyx} from 'react-native-onyx';
4+
import Onyx, {withOnyx} from 'react-native-onyx';
55
import type {ValueOf} from 'type-fest';
66
import ActiveGuidesEventListener from '@components/ActiveGuidesEventListener';
77
import ComposeProviders from '@components/ComposeProviders';
@@ -50,7 +50,6 @@ import SCREENS from '@src/SCREENS';
5050
import type * as OnyxTypes from '@src/types/onyx';
5151
import type {SelectedTimezone, Timezone} from '@src/types/onyx/PersonalDetails';
5252
import {isEmptyObject} from '@src/types/utils/EmptyObject';
53-
import isLoadingOnyxValue from '@src/types/utils/isLoadingOnyxValue';
5453
import type ReactComponentModule from '@src/types/utils/ReactComponentModule';
5554
import beforeRemoveReportOpenedFromSearchRHP from './beforeRemoveReportOpenedFromSearchRHP';
5655
import CENTRAL_PANE_SCREENS from './CENTRAL_PANE_SCREENS';
@@ -66,6 +65,17 @@ import OnboardingModalNavigator from './Navigators/OnboardingModalNavigator';
6665
import RightModalNavigator from './Navigators/RightModalNavigator';
6766
import WelcomeVideoModalNavigator from './Navigators/WelcomeVideoModalNavigator';
6867

68+
type AuthScreensProps = {
69+
/** Session of currently logged in user */
70+
session: OnyxEntry<OnyxTypes.Session>;
71+
72+
/** The report ID of the last opened public room as anonymous user */
73+
lastOpenedPublicRoomID: OnyxEntry<string>;
74+
75+
/** The last Onyx update ID was applied to the client */
76+
initialLastUpdateIDAppliedToClient: OnyxEntry<number>;
77+
};
78+
6979
const loadReportAttachments = () => require<ReactComponentModule>('../../../pages/home/report/ReportAttachments').default;
7080
const loadValidateLoginPage = () => require<ReactComponentModule>('../../../pages/ValidateLoginPage').default;
7181
const loadLogOutPreviousUserPage = () => require<ReactComponentModule>('../../../pages/LogOutPreviousUserPage').default;
@@ -213,10 +223,7 @@ const modalScreenListenersWithCancelSearch = {
213223
},
214224
};
215225

216-
function AuthScreens() {
217-
const [session, sessionStatus] = useOnyx(ONYXKEYS.SESSION);
218-
const [lastOpenedPublicRoomID, lastOpenedPublicRoomIDStatus] = useOnyx(ONYXKEYS.LAST_OPENED_PUBLIC_ROOM_ID);
219-
const [initialLastUpdateIDAppliedToClient, initialLastUpdateIDAppliedToClientStatus] = useOnyx(ONYXKEYS.ONYX_UPDATES_LAST_UPDATE_ID_APPLIED_TO_CLIENT);
226+
function AuthScreens({session, lastOpenedPublicRoomID, initialLastUpdateIDAppliedToClient}: AuthScreensProps) {
220227
const styles = useThemeStyles();
221228
const StyleUtils = useStyleUtils();
222229
const {shouldUseNarrowLayout, onboardingIsMediumOrLargerScreenWidth, isSmallScreenWidth} = useResponsiveLayout();
@@ -398,9 +405,6 @@ function AuthScreens() {
398405
// Prevent unnecessary scrolling
399406
cardStyle: styles.cardStyleNavigator,
400407
};
401-
if (isLoadingOnyxValue(sessionStatus, lastOpenedPublicRoomIDStatus, initialLastUpdateIDAppliedToClientStatus)) {
402-
return;
403-
}
404408

405409
return (
406410
<ComposeProviders components={[OptionsListContextProvider, SearchContextProvider]}>
@@ -579,4 +583,16 @@ function AuthScreens() {
579583

580584
AuthScreens.displayName = 'AuthScreens';
581585

582-
export default memo(AuthScreens, () => true);
586+
const AuthScreensMemoized = memo(AuthScreens, () => true);
587+
588+
export default withOnyx<AuthScreensProps, AuthScreensProps>({
589+
session: {
590+
key: ONYXKEYS.SESSION,
591+
},
592+
lastOpenedPublicRoomID: {
593+
key: ONYXKEYS.LAST_OPENED_PUBLIC_ROOM_ID,
594+
},
595+
initialLastUpdateIDAppliedToClient: {
596+
key: ONYXKEYS.ONYX_UPDATES_LAST_UPDATE_ID_APPLIED_TO_CLIENT,
597+
},
598+
})(AuthScreensMemoized);

tests/ui/PaginationTest.tsx

-4
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,6 @@ async function signInAndGetApp(): Promise<void> {
238238
},
239239
});
240240

241-
await Onyx.set(ONYXKEYS.ONYX_UPDATES_LAST_UPDATE_ID_APPLIED_TO_CLIENT, 1);
242-
243-
await Onyx.set(ONYXKEYS.LAST_OPENED_PUBLIC_ROOM_ID, '1');
244-
245241
// We manually setting the sidebar as loaded since the onLayout event does not fire in tests
246242
AppActions.setSidebarLoaded();
247243
});

tests/ui/UnreadIndicatorsTest.tsx

-4
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,6 @@ function signInAndGetAppWithUnreadChat(): Promise<void> {
181181
[USER_B_ACCOUNT_ID]: TestHelper.buildPersonalDetails(USER_B_EMAIL, USER_B_ACCOUNT_ID, 'B'),
182182
});
183183

184-
await Onyx.set(ONYXKEYS.ONYX_UPDATES_LAST_UPDATE_ID_APPLIED_TO_CLIENT, 1);
185-
186-
await Onyx.set(ONYXKEYS.LAST_OPENED_PUBLIC_ROOM_ID, '1');
187-
188184
// We manually setting the sidebar as loaded since the onLayout event does not fire in tests
189185
AppActions.setSidebarLoaded();
190186
return waitForBatchedUpdatesWithAct();

0 commit comments

Comments
 (0)