-
Notifications
You must be signed in to change notification settings - Fork 3k
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: buildOnyxDataForInvoice to use a parameter object. #57294
refactor: buildOnyxDataForInvoice to use a parameter object. #57294
Conversation
Signed-off-by: krishna2323 <[email protected]>
@dominictb 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] |
Reviewer Checklist
Screenshots/VideosAndroid: NativeScreen.Recording.2025-02-23.at.22.07.54.movAndroid: mWeb ChromeScreen.Recording.2025-02-23.at.20.56.49.moviOS: NativeScreen.Recording.2025-02-23.at.21.24.22.moviOS: mWeb SafariScreen.Recording.2025-02-23.at.20.55.19.movMacOS: Chrome / SafariScreen.Recording.2025-02-23.at.20.50.48.movMacOS: DesktopScreen.Recording.2025-02-23.at.21.02.11.mov |
I faced some issues while building Android App, will record soon |
src/libs/actions/IOU.ts
Outdated
type BuildOnyxDataForInvoiceParams = { | ||
chatReport: OnyxEntry<OnyxTypes.Report>; | ||
iouReport: OnyxTypes.Report; | ||
transaction: OnyxTypes.Transaction; | ||
chatCreatedAction: OptimisticCreatedReportAction; | ||
iouCreatedAction: OptimisticCreatedReportAction; | ||
iouAction: OptimisticIOUReportAction; | ||
optimisticPersonalDetailListAction: OnyxTypes.PersonalDetailsList; | ||
reportPreviewAction: ReportAction; | ||
optimisticPolicyRecentlyUsedCategories: string[]; | ||
optimisticPolicyRecentlyUsedTags: OnyxTypes.RecentlyUsedTags; | ||
isNewChatReport: boolean; | ||
transactionThreadReport: OptimisticChatReport; | ||
transactionThreadCreatedReportAction: OptimisticCreatedReportAction | null; | ||
policy?: OnyxEntry<OnyxTypes.Policy>; | ||
policyTagList?: OnyxEntry<OnyxTypes.PolicyTagLists>; | ||
policyCategories?: OnyxEntry<OnyxTypes.PolicyCategories>; | ||
optimisticRecentlyUsedCurrencies?: string[]; | ||
companyName?: string; | ||
companyWebsite?: string; | ||
}; |
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.
Can we please group together all chat, iou, policy, etc, related params like we do for MoneyRequestOptimisticParams
?
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.
@dominictb, I have regrouped the params, could you please look at it once? Thanks!
…ceParams. Signed-off-by: krishna2323 <[email protected]>
src/libs/actions/IOU.ts
Outdated
transactionThreadReport: OptimisticChatReport; | ||
transactionThreadCreatedReportAction: OptimisticCreatedReportAction | null; | ||
}; | ||
policyParams: { |
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 think we should use RequestMoneyPolicyParams
for policyParams and create new type for optimisticData
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.
updated.
@Krishna2323 Almost done, I left 1 minor comment only |
Signed-off-by: krishna2323 <[email protected]>
src/libs/actions/IOU.ts
Outdated
type BuildOnyxDataForInvoiceParams = { | ||
chat: { | ||
chatReport: OnyxEntry<OnyxTypes.Report>; | ||
chatCreatedAction: OptimisticCreatedReportAction; | ||
reportPreviewAction: ReportAction; | ||
isNewChatReport: boolean; | ||
}; | ||
iou: { | ||
iouCreatedAction: OptimisticCreatedReportAction; | ||
iouAction: OptimisticIOUReportAction; | ||
iouReport: OnyxTypes.Report; | ||
}; | ||
transactionParams: { | ||
transaction: OnyxTypes.Transaction; | ||
transactionThreadReport: OptimisticChatReport; | ||
transactionThreadCreatedReportAction: OptimisticCreatedReportAction | null; | ||
}; | ||
policyParams: RequestMoneyPolicyParams; | ||
optimisticData: { | ||
optimisticRecentlyUsedCurrencies?: string[]; | ||
optimisticPolicyRecentlyUsedCategories: string[]; | ||
optimisticPolicyRecentlyUsedTags: OnyxTypes.RecentlyUsedTags; | ||
optimisticPersonalDetailListAction: OnyxTypes.PersonalDetailsList; | ||
}; | ||
companyName?: string; | ||
companyWebsite?: string; | ||
}; |
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 good, but please remove the redundant prefixes in the sub-objects. It's redundant to have to write iou.iouSomeFieldName
. For example, like we have here
Lines 399 to 403 in 78a4032
iou: { | |
report: OnyxTypes.Report; | |
createdAction: OptimisticCreatedReportAction; | |
action: OptimisticIOUReportAction; | |
}; |
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, I removed the prefixes, but what’s the correct way to access the nested value? Should we use iou.iouCreatedAction.reportActionID
, or destructuring is preferred?
I have implemented it using destructuring. Could you please confirm if this is correct? Thanks!
const {
chat: {report: chatReport, createdAction: chatCreatedAction, reportPreviewAction, isNewReport: isNewChatReport},
iou: {createdAction: iouCreatedAction, action: iouAction, report: iouReport},
transactionParams: {transaction, threadReport: transactionThreadReport, threadCreatedReportAction: transactionThreadCreatedReportAction},
policyParams: {policy, policyTagList, policyCategories},
optimisticData: {
policyRecentlyUsedCategories: optimisticPolicyRecentlyUsedCategories,
policyRecentlyUsedTags: optimisticPolicyRecentlyUsedTags,
personalDetailListAction: optimisticPersonalDetailListAction,
recentlyUsedCurrencies: optimisticRecentlyUsedCurrencies,
},
companyName,
companyWebsite,
} = invoiceParams;
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 think I prefer doing it without de-structuring iou.createdAction.reportActionID
because then it's less redundant. However, I have allowed it with de-structuring before and it does have the advantage that you don't have to update all the places these variables are used.
If you would please update it to use dot notation I would appreciate that and I think it sets a good standard moving forward. Part of the goal of this refactor is to reduce the large number of variables to manage, and have a small number of object variables that are well organized and documented by their types.
Signed-off-by: krishna2323 <[email protected]>
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 update. It looks good as is, but there are conflicts. So while you resolve those please also update it to use dot notation to access param fields. Thanks for sticking with this one.
Please DM me when you get it updated and I can review quickly if I'm online |
Signed-off-by: krishna2323 <[email protected]>
Signed-off-by: krishna2323 <[email protected]>
…iceParams. Signed-off-by: krishna2323 <[email protected]>
Signed-off-by: krishna2323 <[email protected]>
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.
Great, thank you!
✋ 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.1.7-0 🚀
|
Explanation of Change
Fixed Issues
$ #57256
PROPOSAL: #57256 (comment)
Tests
invoices
enabled.Send invoice
> Enter amountSend invoice
Offline tests
invoices
enabled.Send invoice
> Enter amountSend invoice
QA Steps
invoices
enabled.Send invoice
> Enter amountSend invoice
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
android_native.mp4
Android: mWeb Chrome
android_chrome.mp4
iOS: Native
ios_native.mp4
iOS: mWeb Safari
ios_safari.mp4
MacOS: Chrome / Safari
web_chrome.mp4
MacOS: Desktop
desktop_app.mp4