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.
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.
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.
[`${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.
[`${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:
***@***.***>
|
| 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.
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 |
|
✋ 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 Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.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