-
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
Issue 39091 - use waitForCollectionCallback #40233
Issue 39091 - use waitForCollectionCallback #40233
Conversation
@tgolen @shubham1206agra I won't be able to continue this PR for another 9 hours. Feel free to leave a review and I'll run through the checklist when I'm back. |
src/libs/ReportUtils.ts
Outdated
|
||
const reportID = CollectionUtils.extractCollectionItemID(key); | ||
reportActionsByReport[reportID] = actions; | ||
reportActionsByReport = Object.fromEntries(Object.entries(actions).map(([key, value]) => [CollectionUtils.extractCollectionItemID(key as `reportActions_${string}`), value])); |
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.
From looking at other places in the code that use waitForCollectionCallback
, is this .map()
necessary? (same comment goes for the other places)
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 believe it is necessary unless we would prefer to access reports by report id using
[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`]
instead of the reportID
, I think it is better that we don't change too much of the functionality of this. In fact I'm going to revert some changes I made to SidebarUtils
, so that the file is closer to its original functionality.
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.
[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`]
is the most common pattern used in the code. Looking at IOU.ts
for example and the allReports
object. All of the references look like:
iouReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${chatReport.iouReportID}`] ?? null;
I'm not able to find any waitForCollectionCallback: true
instance that is using a map()
. I think that's what allows for a performance gain. Since the code currently in this PR replaces n
callbacks with a map that does n
invocations, there really isn't any performance gain.
src/libs/ReportUtils.ts
Outdated
|
||
const reportID = CollectionUtils.extractCollectionItemID(key); | ||
reportActionsByReport[reportID] = actions; | ||
reportActionsByReport = Object.fromEntries(Object.entries(actions).map(([key, value]) => [CollectionUtils.extractCollectionItemID(key as `reportActions_${string}`), value])); |
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.
[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`]
is the most common pattern used in the code. Looking at IOU.ts
for example and the allReports
object. All of the references look like:
iouReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${chatReport.iouReportID}`] ?? null;
I'm not able to find any waitForCollectionCallback: true
instance that is using a map()
. I think that's what allows for a performance gain. Since the code currently in this PR replaces n
callbacks with a map that does n
invocations, there really isn't any performance gain.
I agree. I’ll have the PR ready for a formal review this evening.
…On Tue, Apr 16, 2024 at 9:06 AM Tim Golen ***@***.***> wrote:
***@***.**** requested changes on this pull request.
------------------------------
In src/libs/ReportUtils.ts
<#40233 (comment)>:
> return;
}
-
- const reportID = CollectionUtils.extractCollectionItemID(key);
- reportActionsByReport[reportID] = actions;
+ reportActionsByReport = Object.fromEntries(Object.entries(actions).map(([key, value]) => [CollectionUtils.extractCollectionItemID(key as `reportActions_${string}`), value]));
[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`] is the most common
pattern used in the code. Looking at IOU.ts for example and the allReports
object. All of the references look like:
iouReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${chatReport.iouReportID}`] ?? null;
I'm not able to find any waitForCollectionCallback: true instance that is
using a map(). I think that's what allows for a performance gain. Since
the code currently in this PR replaces n callbacks with a map that does n
invocations, there really isn't any performance gain.
—
Reply to this email directly, view it on GitHub
<#40233 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AL7TPLKTHEODJQXQF3D2ENLY5UV7XAVCNFSM6AAAAABGHHFVXSVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDAMBTG42TIMBWGY>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
@@ -5714,9 +5712,10 @@ function shouldDisableThread(reportAction: OnyxEntry<ReportAction>, reportID: st | |||
const isIOUAction = ReportActionsUtils.isMoneyRequestAction(reportAction); | |||
const isWhisperAction = ReportActionsUtils.isWhisperAction(reportAction) || ReportActionsUtils.isActionableTrackExpense(reportAction); | |||
const isArchivedReport = isArchivedRoom(getReport(reportID)); | |||
const isActionDisabled = CONST.REPORT.ACTIONS.THREAD_DISABLED.some((action: string) => action === reportAction?.actionName); |
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 did this so that the linter would pass.
Looks good, will test today. |
Reviewer Checklist
Screenshots/VideosAndroid: Native01_Android_Native.mp4Android: mWeb Chrome02_Android_Chrome.mp4iOS: Native03_iOS_Native.mp4iOS: mWeb Safari04_iOS_Safari.mp4MacOS: Chrome / Safari05_MacOS_Chrome.mp4MacOS: Desktop06_MacOS_Desktop.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.
LGTM.
✋ 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/tgolen in version: 1.4.63-0 🚀
|
🚀 Deployed to production by https://github.com/mountiny in version: 1.4.63-21 🚀
|
Details
Fixed Issues
$ #39091
PROPOSAL: N/A
Tests
Offline tests
QA Steps
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.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.mov
Android: mWeb Chrome
Android.Web.mov
iOS: Native
iOS.Native.mov
iOS: mWeb Safari
iOS.Web.mov
MacOS: Chrome / Safari
Web.mov
MacOS: Desktop
Desktop.mov