-
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
[TS migration] Migrate 'AppNavigator' lib to TypeScript #29157
[TS migration] Migrate 'AppNavigator' lib to TypeScript #29157
Conversation
# Conflicts: # src/SCREENS.ts
src/libs/Navigation/AppNavigator/createCustomStackNavigator/CustomRouter.ts
Outdated
Show resolved
Hide resolved
# Conflicts: # src/SCREENS.ts # src/libs/Navigation/AppNavigator/AuthScreens.tsx # src/libs/Navigation/AppNavigator/ModalStackNavigators.js # src/libs/Navigation/AppNavigator/Navigators/CentralPaneNavigator.tsx # src/libs/Navigation/AppNavigator/Navigators/Overlay.tsx # src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx # src/libs/Navigation/AppNavigator/PublicScreens.tsx # src/libs/Navigation/AppNavigator/RHPScreenOptions.ts # src/libs/Navigation/AppNavigator/ReportScreenIDSetter.ts # src/libs/Navigation/AppNavigator/ReportScreenWrapper.js # src/libs/Navigation/AppNavigator/createCustomStackNavigator/CustomRouter.ts # src/libs/Navigation/AppNavigator/createCustomStackNavigator/index.js # src/libs/Navigation/AppNavigator/getRootNavigatorScreenOptions.ts # src/libs/Navigation/AppNavigator/index.tsx # src/libs/Navigation/AppNavigator/modalCardStyleInterpolator.ts # src/styles/cardStyles/types.ts # src/types/onyx/Report.ts
# Conflicts: # src/SCREENS.ts # src/libs/actions/App.ts
# Conflicts: # src/SCREENS.ts # src/libs/Navigation/AppNavigator/AuthScreens.tsx # src/libs/Navigation/AppNavigator/ModalStackNavigators.js # src/libs/Navigation/AppNavigator/Navigators/Overlay.tsx # src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx # src/libs/Navigation/Navigation.js # src/types/onyx/Report.ts
# Conflicts: # src/libs/Navigation/AppNavigator/ModalStackNavigators.js # src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx # src/libs/Navigation/AppNavigator/RHPScreenOptions.ts # src/libs/Navigation/AppNavigator/getRootNavigatorScreenOptions.ts
# Conflicts: # src/libs/Navigation/AppNavigator/ReportScreenIDSetter.ts
src/libs/Navigation/AppNavigator/createCustomStackNavigator/CustomRouter.ts
Outdated
Show resolved
Hide resolved
src/libs/Navigation/AppNavigator/createCustomStackNavigator/CustomRouter.ts
Outdated
Show resolved
Hide resolved
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.
Left comments. Overall, LGTM!
src/libs/Navigation/AppNavigator/createCustomStackNavigator/CustomRouter.ts
Outdated
Show resolved
Hide resolved
src/libs/Navigation/AppNavigator/createCustomStackNavigator/CustomRouter.ts
Outdated
Show resolved
Hide resolved
src/libs/Navigation/AppNavigator/createCustomStackNavigator/CustomRouter.ts
Outdated
Show resolved
Hide resolved
src/libs/Navigation/AppNavigator/createCustomStackNavigator/CustomRouter.ts
Outdated
Show resolved
Hide resolved
src/libs/Navigation/AppNavigator/createCustomStackNavigator/CustomRouter.ts
Outdated
Show resolved
Hide resolved
src/libs/Navigation/AppNavigator/createCustomStackNavigator/CustomRouter.ts
Outdated
Show resolved
Hide resolved
Reviewer Checklist
Screenshots/VideosAndroid: NativeScreen.Recording.2023-12-06.at.4.31.32.AM.movAndroid: mWeb ChromeScreen.Recording.2023-12-06.at.4.30.03.AM.moviOS: NativeScreen.Recording.2023-12-06.at.4.28.37.AM.moviOS: mWeb SafariScreen.Recording.2023-12-06.at.4.27.23.AM.movMacOS: Chrome / SafariScreen.Recording.2023-12-06.at.4.17.16.AM.movMacOS: DesktopScreen.Recording.2023-12-06.at.4.24.46.AM.mov |
mode="modal" | ||
// We are disabling the default keyboard handling here since the automatic behavior is to close a | ||
// keyboard that's open when swiping to dismiss a modal. In those cases, pressing the back button on | ||
// a header will briefly open and close the keyboard and crash Android. | ||
// eslint-disable-next-line react/jsx-props-no-multi-spaces | ||
keyboardHandlingEnabled={false} |
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.
Why is this being removed?
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.
@allroundexperts Please, see this discussion for the context
return getTopMostReportIDFromRHP(topmostRoute.state); | ||
} | ||
|
||
if (topmostRoute.params && topmostRoute.params.reportID) { | ||
if (topmostRoute?.params && 'reportID' in topmostRoute.params && typeof topmostRoute.params.reportID === 'string' && topmostRoute.params.reportID) { |
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.
Curious why && typeof topmostRoute.params.reportID === 'string' && topmostRoute.params.reportID
is needed? Shouldn't 'reportID' in topmostRoute.params
be enough?
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.
@allroundexperts Not really, we need to narrow down the type to make sure reportID
is string
, that's why
addCentralPaneNavigatorRoute(partialState); | ||
} | ||
const state = stackRouter.getRehydratedState(partialState, {routeNames, routeParamList}); | ||
const state = stackRouter.getRehydratedState(partialState, {routeNames, routeParamList, routeGetIdList}); |
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.
Why is routeGetIdList
being added here?
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.
@@ -13,7 +13,7 @@ let hasPendingNetworkCheck = false; | |||
|
|||
// Holds all of the callbacks that need to be triggered when the network reconnects | |||
let callbackID = 0; | |||
const reconnectionCallbacks: Record<string, () => Promise<void>> = {}; | |||
const reconnectionCallbacks: Record<string, () => void> = {}; |
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.
Why isn't this a promise
anymore?
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.
Because the callback passed to reconnect
function is not a Promise
App/src/libs/Navigation/AppNavigator/AuthScreens.tsx
Lines 156 to 162 in d6c824b
NetworkConnection.onReconnect(() => { | |
if (isLoadingApp) { | |
App.openApp(); | |
} else { | |
App.reconnectApp(lastUpdateIDAppliedToClient); | |
} | |
}); |
type GetNavigationModalCardStylesParams = {isSmallScreenWidth: number}; | ||
|
||
type GetNavigationModalCardStyles = (params: GetNavigationModalCardStylesParams) => ViewStyle; | ||
type GetNavigationModalCardStyles = () => ViewStyle; |
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.
Why the params are being removed?
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.
@allroundexperts Because this type is used for typing the functions without params:
const getNavigationModalCardStyles: GetNavigationModalCardStyles = () => ({ |
const getNavigationModalCardStyles: GetNavigationModalCardStyles = () => ({ |
const getNavigationModalCardStyles: GetNavigationModalCardStyles = () => ({ |
/** If the admin room should be opened */ | ||
openOnAdminRoom?: boolean; | ||
|
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.
Why is this being added?
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.
Found the following two console warnings. I'm quite sure that these are not related to this PR but still, it would be good to confirm these before merging @VickyStash! |
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.
Tests well. I'm not blocking the approval because of my comments because this is such a high priority PR.
We did not find an internal engineer to review this PR, trying to assign a random engineer to #24935 as well as to this PR... Please reach out for help on Slack if no one gets assigned! |
@allroundexperts I wasn't able to reproduce a console warning from the first screenshot, do you remember the steps of reproduction? |
@Gonals The SWM team is currently working on navigation refactoring, and this migration could speed up things - so please prioritize this one 🙏 |
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.
This looks good to me and all comments have been answered.
Ahh, damn. @VickyStash, seems like we have some conflicts. I'll merge once they are solved |
# Conflicts: # src/libs/Navigation/AppNavigator/createCustomStackNavigator/CustomRouter.ts
@Gonals Is there anything that prevents you from merging? 😅 |
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
🚀 Deployed to staging by https://github.com/Gonals in version: 1.4.9-0 🚀
|
1 similar comment
🚀 Deployed to staging by https://github.com/Gonals in version: 1.4.9-0 🚀
|
🚀 Deployed to production by https://github.com/yuwenmemon in version: 1.4.9-5 🚀
|
Details
[TS migration] Migrate 'AppNavigator' lib to TypeScript
Fixed Issues
$ #24935
PROPOSAL: N/A
Tests
Note: Test the app generally, navigating through the app, login screen, settings, report screen, etc
Offline tests
N/A
QA Steps
Note: Test the app generally, navigating through the app, login screen, settings, report screen, etc
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)/** comment above it */
this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Android: Native
android1.mp4
Android: mWeb Chrome
android_web1.mp4
iOS: Native
ios1.mp4
iOS: mWeb Safari
ios_web1.mp4
MacOS: Chrome / Safari
web1.mp4
MacOS: Desktop
desktop1.mp4