-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
[$250] Remove exported ReportUtils.getReport()
#40316
Comments
ReportUtils.getReport()
ReportUtils.getReport()
Job added to Upwork: https://www.upwork.com/jobs/~014f8c2e6e8d2c1390 |
Triggered auto assignment to Contributor-plus team member for initial proposal review - @s77rt ( |
Triggered auto assignment to @MitchExpensify ( |
ProposalPlease re-state the problem that we are trying to solve in this issue.Remove exported ReportUtils.getReport() What is the root cause of that problem?This is a polish issue. What changes do you think we should make in order to solve the problem?There are currently 28 places using let allReports: OnyxCollection<Report>;
Onyx.connect({
key: ONYXKEYS.COLLECTION.REPORT,
waitForCollectionCallback: true,
callback: (value) => (allReports = value),
}); withOnyx(
report: {
key: ({chatReportID}) => `${ONYXKEYS.COLLECTION.REPORT}${chatReportID}`,
},
) What alternative solutions did you explore? (Optional)NA |
ProposalPlease re-state the problem that we are trying to solve in this issue.Remove deprecated ReportUtils.getReport() method What is the root cause of that problem?This is refactor issue What changes do you think we should make in order to solve the problem?
OPTION: We can create a local function in action file to get the report with
What alternative solutions did you explore? (Optional)NA |
@tgolen have we already found a way to synchronize all the Onyx reads? Using |
If most of the code used |
I'm not quite sure how this should help. The first thread was about For the record, |
Yes, this is what I mean. If the report was already fetched in the component, then the report should be passed directly to Keep in mind, I am only speaking to the theory behind it. It's been a long time since I've dug into the |
Passing objects around as parameters just because we cannot reliably fetch them from any place feels like a heavier anti-pattern than the one we are trying to solve by removing |
I think it reflects what I would expect for large collections. This is why I think
I'm not flatly against a singleton, but I think that is a last resort and I have always been concerned that it's the "easy solution" which covers up deeper problems. I'd rather fix the deeper problems, and only when those are completely exhausted, consider using a singleton. |
Why would that be needed? Or what's the difference between calling |
@gijoe0295 @nkdengineer Thank you for your proposals. Given this is a straightforward feature/refactor request we should go with the first proposal (@gijoe0295's proposal) 🎀 👀 🎀 C+ reviewed |
Current assignee @tgolen is eligible for the choreEngineerContributorManagement assigner, not assigning anyone new. |
Before accepting any proposals... @gijoe0295 did you take a look at the references to see if it's easy (or even possible) to get the report using |
Regarding memory usage, I don't think there is that big of an impact. They should all be references to the same objects, so memory is negligible. If I'm wrong about that, please profile it and show the memory problem exists and is significant enough to be concerned about.
You're right that there is no technical difference between the two. The difference for me is a code quality and maintenance issue. As soon as |
@tgolen I investigated and verified that we can use We can optionally migrate to |
Great, thank you for confirming that. Using |
📣 @s77rt 🎉 An offer has been automatically sent to your Upwork account for the Reviewer role 🎉 Thanks for contributing to the Expensify app! |
📣 @gijoe0295 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app! Offer link |
This issue has not been updated in over 15 days. @tgolen, @s77rt, @MitchExpensify, @gijoe0295 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! |
Just bumped the PR |
This is coming from #27262. You can read the issue description there to get the context behind the problem being solved and the mess being cleaned up.
Problem
ReportActionUtils.getReport()
is called from many view components and other action files which is an anti-pattern.Why this is important to fix
It maintains a more pure and exact flow of data through the react application. If the view is using report action data, then it needs to subscribe to the data in Onyx so that it's guaranteed that the data will never be stale or out-of-date.
Solution
withOnyx()
to load the data in view componentsOnyx.connect()
to load the data in other action filesReportUtils.getReport()
and prevent it from being exported by adding a test to https://github.com/Expensify/App/blob/main/tests/actions/EnforceActionExportRestrictions.tsUpwork Automation - Do Not Edit
The text was updated successfully, but these errors were encountered: