perf: optimise composer send behaviour#30168
Conversation
… perf/optimise-composer-send
… perf/optimise-composer-send
… perf/optimise-composer-send
|
@aimane-chnaif 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] |
|
@hurali97 please fix conflict |
… perf/optimise-composer-send
|
Figuring out why Reassure tests are failing and will update the PR accordingly. |
|
@aimane-chnaif All green now ! |
|
As it's failing on main, someone will fix urgently so let's wait |
|
@hurali97 please pull main. It's fixed now |
… perf/optimise-composer-send
return (
<ReportActionItemCreated
reportID={props.report.reportID}
policyID={props.report.policyID}
+ personalDetails={personalDetails}
/>
);Can we apply this change in ReportActionItem.js to fix this issue? Screen.Recording.2024-01-30.at.3.21.41.PM.movScreen.Recording.2024-01-30.at.3.07.50.PM.mov |
… perf/optimise-composer-send
|
@aimane-chnaif Thanks for doing a regression. I have fixed these issues now 👍 |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, Desktop, and Web. Happy testing! 🧪🧪 |
|
Seems like auto-focus composer when switch chat is broken on staging web. Works fine on production. Deploy blocker maybe? (for future reference: staging - v1.4.34-0, production - v1.4.33-5) Screen.Recording.2024-01-31.at.12.03.58.PM.mov |
mountiny
left a comment
There was a problem hiding this comment.
Let's go then, code looks good to me, this was a massive effort, thanks everyone!
mountiny
left a comment
There was a problem hiding this comment.
Let's go then, code looks good to me, this was a massive effort, thanks everyone!
|
✋ 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/mountiny in version: 1.4.35-0 🚀
|
|
I believe this PR caused this regression: #35559 |
| prevProps.report.isOptimisticReport === nextProps.report.isOptimisticReport && | ||
| prevProps.report.statusNum === nextProps.report.statusNum && | ||
| _.isEqual(prevProps.report.pendingFields, nextProps.report.pendingFields) && | ||
| prevProps.currentReportID === nextProps.currentReportID, |
There was a problem hiding this comment.
@hurali97 Not sure this was mentioned before but why keys here are inconsistent with useMemo here?
App/src/pages/home/ReportScreen.js
Lines 173 to 203 in 9ab4fe9
App/src/pages/home/ReportScreen.js
Lines 645 to 661 in 9ab4fe9
notificationPreference is good example. It's added in useMemo but not in memo. This caused #35562
|
🚀 Deployed to production by https://github.com/mountiny in version: 1.4.35-7 🚀
|
| childVisibleActionCount: reportAction.childVisibleActionCount, | ||
| childOldestFourAccountIDs: reportAction.childOldestFourAccountIDs, | ||
| childType: reportAction.childType, | ||
| person: reportAction.person, |
There was a problem hiding this comment.
Is this referenced somehere? I can't find it anywhere.
There was a problem hiding this comment.
Ah that would be for threads, it would have to be used for that little element showing how many replies are in thread, who responded, right?

Details
This fixes major things wrong with
ReportScreenand it's children,ReportActionComposeandComposerWithSuggestions. The highlight is thepersonalDetailsprop fromonyxas on high traffic accountspersonalDetailsbecomes a huge object and is expensive to pass as a prop and have the component render/ re-render. So each time a message is sent, we are manipulating onyx for thereport_,reportActions_andpersonalDetailskeys first with the optimistic data and then with the successful data. Most of theReportScreenand it's children doesn't really needpersonalDetailsas a prop from onyx as they are passing that prop to certain utility functions to calculate for example, icon. So thispersonalDetailsprop can be removed and we can use directly from the utility as we haveOnyx.connectalready present in the utility files.Apart from this, some props including
reportandreportActionshave been simplified to become lightweight so that the can be passed easily down to the children. Previously, we were passing the whole object and it had properties that we don't need. Also, to prevent unnecessary re-rendering ofReportActionComposethe empty state is lifted and moved toReportActionComposealongside theSendButtonandEmojiButton. Also,sortedReportActionsaren't really needed to pass toReportActionsListItemRendereras it uses the prop to only evaluate whether it's a group or not. So we have passed a new propdisplayAsGroupto the component directly instead of passing the whole actions array.Fixed Issues
$ #26347
PROPOSAL: #26347 (comment)
Tests
Testing Steps:
Open a Report and focus the composer
Start typing some letters and then hit send
Once the message is sent, start typing again and then press send
No message should be present in the composer and the behaviour should feel smooth
Verify that no errors appear in the JS console
Offline tests
QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.src/languages/*files and using the translation methodWaiting for Copylabel for a copy review on the original GH to get the correct copy.STYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)/** comment above it */thisproperly so there are no scoping issues (i.e. foronClick={this.submit}the methodthis.submitshould be bound tothisin the constructor)thisare necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);ifthis.submitis never passed to a component event handler likeonClick)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)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-recording.mov
Android: mWeb Chrome
android-web-recording.mov
iOS: Native
ios-recording.mp4
iOS: mWeb Safari
ios-web-recording.mp4
MacOS: Chrome / Safari
web-recording.mov
MacOS: Desktop
desktop-recording.mov