-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Remove the side-loading of data in Task action from the ReportActionUtils #37340
Conversation
@youssef-lr 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: Nativeandroid-native-2024-02-28_16.11.40.mp4Android: mWeb Chromeandroid-chrome-2024-02-28_16.16.53.mp4iOS: Nativeios-native-2024-02-28_16.04.54.mp4iOS: mWeb Safariios-safari-2024-02-28_16.06.39.mp4MacOS: Chrome / Safaridesktop-chrome-2024-02-28_15.57.23.mp4MacOS: Desktopdesktop-app-2024-02-28_16.01.58.mp4 |
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 & LGTM!
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.
LGTM
src/libs/actions/Task.ts
Outdated
/** | ||
* Returns the parentReportAction if the given report is a thread/task. | ||
* | ||
* @deprecated Use Onyx.connect() or withOnyx() instead |
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 deprecated if it's new?
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.
Oops, this is copy/paste. I'll remove it.
* @deprecated Use Onyx.connect() or withOnyx() instead | ||
*/ | ||
function getParentReportAction(report: OnyxEntry<OnyxTypes.Report>): ReportAction | Record<string, never> { | ||
if (!report?.parentReportID || !report.parentReportActionID) { |
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 we need to check for parentReportID
? Can you explain in a comment?
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.
Comment added (but it's kind of self-explanatory too when you look at the next line and see how those properties are used).
* | ||
* @deprecated Use Onyx.connect() or withOnyx() instead | ||
*/ | ||
function getParentReportAction(report: OnyxEntry<OnyxTypes.Report>): ReportAction | Record<string, never> { |
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.
Would it be possible and make sense to pass Report
here and to deleteTask
instead of OnyxEntry<OnyxTypes.Report>
, so that we don't have to check report?
? It looks like we only call deleteTask in one place
It looks like before we were using props.report.reportName
and not props.report?.reportName
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 could revert the changes in deleteTask
to go back to using const taskReport = ReportUtils.getReport(taskReportID);
which returns a Report
and not a OnyxEntry<OnyxTypes.Report>
, but here is why I removed it.
- The view already has the full report object from Onyx
- The view was passing 4 properties of the report object to
deleteTask
and then getting the full report object fromReportUtils.getReport()
- This is inefficient and leads to really bad code and possibly stale data
- By using the same report reference in all the methods, it's assured that the report object will always be correct
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.
Oh yeah I think the change you made was an improvement, so I wasn't suggesting reverting back to the old version, just to go from getParentReportAction(report: OnyxEntry<OnyxTypes.Report>):
to getParentReportAction(report: Report):
, and remove a lot of ?
that would be unnecessary. Is that doable?
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.
You can't simply cast one type to another like that, but I asked about it in Slack and I at least found a way to remove all the optional chaining by adding an early return at the beginning of the method.
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.
That works. I was thinking not just updating the param type --that was to illustrate what I meant, but also the function call Session.checkIfActionIsAllowed(Task.deleteTask(props.report));
, with something like Session.checkIfActionIsAllowed(Task.deleteTask(props.report as Report));
or whatever TS magic helps with that.
I like checking before and returning early tho 👍
@cead22 I merged |
👍 I was leaving it for Youssef |
🚀 Deployed to staging by https://github.com/cead22 in version: 1.4.47-0 🚀
|
🚀 Deployed to production by https://github.com/roryabraham in version: 1.4.47-10 🚀
|
Details
This will ensure that the Task action is using data that it is directly connected to.
Fixed Issues
Part of #27262
Tests
Offline tests
Same as the tests.
QA Steps
Same as the tests
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)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label 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
2024-02-27_11-57-28.mp4
Android: mWeb Chrome
iOS: Native
2024-02-27_11-35-33.mp4
iOS: mWeb Safari
2024-02-27_11-31-01.mp4
MacOS: Chrome / Safari
2024-02-27_11-24-56.mp4
MacOS: Desktop
2024-02-27_11-29-15.mp4