-
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
Refactor IOU.requestMoney function #52231
Conversation
@dukenv0307 Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
src/libs/actions/IOU.ts
Outdated
@@ -164,6 +164,37 @@ type GPSPoint = { | |||
long: number; | |||
}; | |||
|
|||
type RequestMoneyInformation = { |
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 do you group many params into 2 objects: RequestMoneyInformation, RequestMoneyTransactionData? (Why not 1 or 3...?)
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.
I split transaction data into one group and others into another 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.
Thanks @mkzie2,
I understand your idea that RequestMoneyTransactionData should contain the params same as Onyx Transaction. For other params we can store in RequestMoneyInformation
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.
I like splitting things up, but I envisioned it slightly different. How about a RequestMoneyParams
type which contains all fields from RequestMoneyInformation, then within it we have transactionData: RequestMoneyTransactionData
?
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.
I'm leaning towards a Params suffix vs Data too
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.
@neil-marcellini So we will only have one param and in this param we will have some sub param is a object like transactionData
, policyData
,... right?
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.
@neil-marcellini Please help to take a look at my comment above when you have a chance.
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.
@neil-marcellini Bump on the above.
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.
Yes that's right
Reviewer Checklist
Screenshots/VideosAndroid: NativeScreen.Recording.2024-11-08.at.15.58.53.movAndroid: mWeb ChromeScreen.Recording.2024-11-08.at.15.54.33.moviOS: NativeScreen.Recording.2024-11-08.at.15.56.27.moviOS: mWeb SafariScreen.Recording.2024-11-08.at.15.51.48.movMacOS: Chrome / SafariScreen.Recording.2024-11-08.at.15.48.54.movMacOS: DesktopScreen.Recording.2024-11-08.at.16.01.53.mov |
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.
Thanks for this! It's going well so far. I have some suggestions that I think will make it a bit cleaner. I like the idea of having one type for the params, that breaks down into sub-types for fields that naturally group together.
src/libs/actions/IOU.ts
Outdated
@@ -164,6 +164,37 @@ type GPSPoint = { | |||
long: number; | |||
}; | |||
|
|||
type RequestMoneyInformation = { |
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.
I like splitting things up, but I envisioned it slightly different. How about a RequestMoneyParams
type which contains all fields from RequestMoneyInformation, then within it we have transactionData: RequestMoneyTransactionData
?
@neil-marcellini @mkzie2 any updates here? |
Waiting for @mkzie2 to update. Please get back to this in a few days or let us know when you can. |
@neil-marcellini I'm waiting your response here. |
Ah I missed that, yes I think you have the right idea. |
@neil-marcellini I updated. |
Reviewing again |
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.
Looks great to me now, thanks. One last naming change request. Please dm me when you get it updated and I'll approve. We should get another C+ test after that.
src/libs/actions/IOU.ts
Outdated
|
||
type RequestMoneyInformation = { | ||
report: OnyxEntry<OnyxTypes.Report>; | ||
participantData: RequestMoneyParticipantParams; |
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.
Nice I like how these types are set up now!
Sorry to be picky, but let's change this to participantParams instead to match the type name. Let's do the same for all fields with the suffix "Data". Change the suffix to "Params".
@neil-marcellini I updated.
@dukenv0307 Please help to test this again if you're available and dm to @neil-marcellini because I'm requesting to join Expensify Slack. |
@mkzie2 I will re-test your PR cc @neil-marcellini |
LGTM and test well web-resize.mp4 |
DMed to @neil-marcellini cc @mkzie2 |
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.
Thanks for the rename and quick turn around. If you could do another similar PR that would be great! Please post on the linked issue what area you think we should refactor next and I will create a new issue to refactor that piece. Then post your proposal and we can keep moving forward.
@neil-marcellini I commented here. |
✋ 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/neil-marcellini in version: 9.0.66-0 🚀
|
Explanation of Change
Change the params of
requestMoney
function to objectFixed Issues
#50368
PROPOSAL:
Tests
Precondition:
Offline tests
Same as above
QA Steps
// TODO: These must be filled out, or the issue title must include "[No QA]."
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)src/languages/*
files and using the translation methodSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label and/or tagged@Expensify/design
so the design team can review the changes.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
Screen.Recording.2024-11-08.at.13.46.42.mov
Android: mWeb Chrome
Screen.Recording.2024-11-08.at.13.53.21.mov
iOS: Native
Screen.Recording.2024-11-08.at.13.56.25.mov
iOS: mWeb Safari
Screen.Recording.2024-11-08.at.13.49.18.mp4
MacOS: Chrome / Safari
Screen.Recording.2024-11-08.at.13.42.03.mov
MacOS: Desktop
Screen.Recording.2024-11-08.at.13.59.23.mov
Screen.Recording.2024-11-08.at.14.09.25.mov