-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: migrate AuthScreens from withOnyx to useOnyx #49185
Merged
roryabraham
merged 21 commits into
Expensify:main
from
BhuvaneshPatil:49103-onyx-migration
Sep 25, 2024
Merged
Changes from 6 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
43746db
chore: migrate withOnyx to useOnyx
BhuvaneshPatil 4df69bb
lint fix
BhuvaneshPatil 72c8de9
Merge branch 'main' of https://github.com/Expensify/App into 49103-on…
BhuvaneshPatil 94b1edd
revert podfile changes
BhuvaneshPatil b727cc4
revert podfile changes
BhuvaneshPatil 250275b
fix showing indicator
BhuvaneshPatil b7c4821
Merge branch 'main' of https://github.com/Expensify/App into 49103-on…
BhuvaneshPatil 6dc4b1b
Merge branch 'main' of https://github.com/Expensify/App into 49103-on…
BhuvaneshPatil 126c750
Merge branch 'main' of https://github.com/Expensify/App into 49103-on…
BhuvaneshPatil e605f51
refactoring
BhuvaneshPatil e00d4c6
chore: migrate withOnyx to useOnyx
BhuvaneshPatil ba4e4ca
lint fix
BhuvaneshPatil 61afdee
revert podfile changes
BhuvaneshPatil 003585e
revert podfile changes
BhuvaneshPatil 34dd64d
modify
BhuvaneshPatil 4f3af39
refactoring
BhuvaneshPatil b5a4e3a
fix tests
BhuvaneshPatil 698d2c9
Merge branch '49103-onyx-migration' of https://github.com/BhuvaneshPa…
BhuvaneshPatil f24a9e6
Merge branch 'main' of https://github.com/Expensify/App into 49103-on…
BhuvaneshPatil de337ac
fix lint
BhuvaneshPatil 99edd39
fix test
BhuvaneshPatil File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -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, {withOnyx} from 'react-native-onyx'; | ||||||
import Onyx, {useOnyx} from 'react-native-onyx'; | ||||||
import type {ValueOf} from 'type-fest'; | ||||||
import ComposeProviders from '@components/ComposeProviders'; | ||||||
import OptionsListContextProvider from '@components/OptionListContextProvider'; | ||||||
|
@@ -47,6 +47,7 @@ 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 isLoadingOnyxValue from '@src/types/utils/isLoadingOnyxValue'; | ||||||
import type ReactComponentModule from '@src/types/utils/ReactComponentModule'; | ||||||
import CENTRAL_PANE_SCREENS from './CENTRAL_PANE_SCREENS'; | ||||||
import createCustomStackNavigator from './createCustomStackNavigator'; | ||||||
|
@@ -61,17 +62,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<OnyxTypes.Session>; | ||||||
|
||||||
/** The report ID of the last opened public room as anonymous user */ | ||||||
lastOpenedPublicRoomID: OnyxEntry<string>; | ||||||
|
||||||
/** The last Onyx update ID was applied to the client */ | ||||||
initialLastUpdateIDAppliedToClient: OnyxEntry<number>; | ||||||
}; | ||||||
|
||||||
const loadReportAttachments = () => require<ReactComponentModule>('../../../pages/home/report/ReportAttachments').default; | ||||||
const loadValidateLoginPage = () => require<ReactComponentModule>('../../../pages/ValidateLoginPage').default; | ||||||
const loadLogOutPreviousUserPage = () => require<ReactComponentModule>('../../../pages/LogOutPreviousUserPage').default; | ||||||
|
@@ -211,7 +201,11 @@ const modalScreenListenersWithCancelSearch = { | |||||
}, | ||||||
}; | ||||||
|
||||||
function AuthScreens({session, lastOpenedPublicRoomID, initialLastUpdateIDAppliedToClient}: AuthScreensProps) { | ||||||
function AuthScreens() { | ||||||
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); | ||||||
const isSessionLoading = isLoadingOnyxValue(sessionStatus, lastOpenedPublicRoomIDStatus, initialLastUpdateIDAppliedToClientStatus); | ||||||
const styles = useThemeStyles(); | ||||||
const StyleUtils = useStyleUtils(); | ||||||
const {shouldUseNarrowLayout, onboardingIsMediumOrLargerScreenWidth, isSmallScreenWidth} = useResponsiveLayout(); | ||||||
|
@@ -390,6 +384,9 @@ function AuthScreens({session, lastOpenedPublicRoomID, initialLastUpdateIDApplie | |||||
// Prevent unnecessary scrolling | ||||||
cardStyle: styles.cardStyleNavigator, | ||||||
}; | ||||||
if (isSessionLoading) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
return; | ||||||
} | ||||||
|
||||||
return ( | ||||||
<ComposeProviders components={[OptionsListContextProvider, SearchContextProvider]}> | ||||||
|
@@ -567,14 +564,4 @@ AuthScreens.displayName = 'AuthScreens'; | |||||
|
||||||
const AuthScreensMemoized = memo(AuthScreens, () => true); | ||||||
|
||||||
export default withOnyx<AuthScreensProps, AuthScreensProps>({ | ||||||
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; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.