Closed tgolen closed 2 months ago
Adding @aimane-chnaif to the GH as he helped review the PR: https://expensify.slack.com/archives/C02NK2DQWUX/p1694749699352029
I'm slowly working my way through these, but I wasn't able to get to any of them this week.
I wrote a new PR for the next one on the list today.
I haven't had time to do any additional work on this.
Coming from https://expensify.slack.com/archives/C01GTK53T8Q/p1688630003862989, here are some util functions that currently depend on Onyx.connect
which I think can be replaced with withOnyx
.
CardUtils | isExpensifyCard, isCorporateCard, getCardDescription |
---|---|
CurrencyUtils | getCurrenyDecimals. getCurrencySymbol, isValidCurrencyCode |
GroupChatUtils | getGroupChatName |
LocalePhoneNumber | formatPhoneNumber |
LoginUtils | appendCountryCode |
PersonalDetailsUtils | getAccountIDsByLogins, getLoginsByAccountIDs |
ReportActionsUtils | getLastVisibleAction, getReportAction, getReportPreviewAction, getAllReportActions, findPreviousAction |
TransactionUtils | getAllReportTransactions |
PersonalDetails | getDisplayName, getDisplayNameForTypingIndicator |
ReimbursementAccount/store.js | hasCreditBankAccount |
Thanks @bernhardoj. What do you think of this approach?
getParentReportAction()
and the others)@tgolen oh, my bad, I didn't mean to completely drop the whole function.
What I mean is more like replacing the source of the onyx data from Onyx.connect
to withOnyx
, for example, getGroupChatName
.
getGroupChatName
depends on ONYXKEYS.PERSONAL_DETAILS_LIST
. Currently, we get the onyx data with Onyx.connect
which could break the reactive behavior.
To fix it, we should pass the personal details onyx from the component that uses it.
function getGroupChatName(report, personalDetails) {}
getGroupChatName(report, personalDetails)
withOnyx({
personalDetails: {key: ONYXKEYS.PERSONAL_DETAILS_LIST}
})
For the plan, I think we can immediately start tackling each function. But there are some function that has a lot of usage which I think can be split into a few parts.
OK, yeah, I know what you mean now. @marcaaron and I have gone back and forth on this topic, and generally we've settled in a place where if there is no problem, then we have left it alone. However, I think it's a safer environment in general if data is usually fetched from withOnyx
and then passed to action files. There are some performance optimizations that can be gained by having less things in withOnyx
though, so there will always be some kind of balance we have to determine. For now, let's try to wrap up the current methods that I've marked as deprecated, and then we can tackle these one-by-one and figure out what to do with them (if anything).
Sounds good 👍
This issue has not been updated in over 15 days. @tgolen eroding to Monthly issue.
P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do!
I've got PRs for the few remaining components 🎉
This issue has not been updated in over 15 days. @tgolen eroding to Monthly issue.
P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do!
Job added to Upwork: https://www.upwork.com/jobs/~0156f7187832f56740
Triggered auto assignment to Contributor Plus for review of internal employee PR - @jjcoffee (Internal
)
@jjcoffee could you please do a C+ review on https://github.com/Expensify/App/pull/37340?
@tgolen Sure, will get to that today!
ReportUtils.getPolicy()
which I've added to the listReportUtils
once all the current issues are doneReportUtils
and make sure it is not exporting anything "bad", then this issue can be closedThis issue has not been updated in over 15 days. @tgolen eroding to Monthly issue.
P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do!
ReportUtils
is the only remaining item, but I took a look at it and I think it's mostly fine for now so I am going to close this out.
Problem
These methods are anti-patterns because they are most always used for loading data into a component without using
withOnyx()
. This breaks the data flow of a react application. (data is coming from somewhere that is not props or state and cannot be debugged in react dev tools).Solution
Switch all references to properly use
withOnyx()
for components andconnect()
for libs.Components
MoneyRequestView
@tgolen https://github.com/Expensify/App/pull/37703HeaderView
@tgolen https://github.com/Expensify/App/pull/37913ReportActionsListItemRenderer
@tgolen https://github.com/Expensify/App/pull/37449getParentReport()
@tgolen https://github.com/Expensify/App/pull/38356Libs
Upwork Automation - Do Not Edit