forked from Expensify/App
-
Notifications
You must be signed in to change notification settings - Fork 1
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
[WIP] Performance: chat input #12
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…y-app-fork into perf/composer-investigations
…ction' of github.com:margelo/expensify-app-fork into perf/composer-investigations
…ction' of github.com:margelo/expensify-app-fork into perf/composer-investigations
…y-app-fork into refactor-report-action-compose
…ction' into refactor-report-action-compose
This reverts commit eb9baf8.
This reverts commit 9739c08.
move actionButtonRef
…actor-report-action-compose
…y-app-fork into refactor-report-action-compose
…ction' of github.com:margelo/expensify-app-fork into refactor-report-action-compose
Co-authored-by: Vit Horacek <[email protected]>
Co-authored-by: Vit Horacek <[email protected]>
hannojg
force-pushed
the
refactor-report-action-compose
branch
from
August 24, 2023 13:51
1b96be0
to
9b7c07b
Compare
perunt
pushed a commit
that referenced
this pull request
Feb 13, 2024
kirillzyusko
pushed a commit
that referenced
this pull request
May 7, 2024
…nditions Travel/terms and conditions
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Details
This PR improves the performance of the
ReportActionCompose
component greatly.The main improvement is that we moved state down into separated components. In the
ReportActionCompose
component we render a lot of items, such as the send button, emoji button, a menu for attachments, attachment picker popups, the composer itself, comment exceeding notice, mention suggestions, emoji suggestions, etc. When we entered one letter all the top level state was updated multiple times, leading into a lot of re-renders for all the mentioned components.So, to achieve a better performance we needed to break out more separate components. This also cleaned up the
ReportActionCompose
component, it went down from1362
lines to410
lines, thus becoming a lot easier to read and maintain.However, this made the PR a bit larger than anticipated. The following gives an overview of the changes to help review this PR.
Note
I'd recommend first looking at the code itself and understanding its structure, and then checking the specific diffs of this PR.
The
ReportActionCompose
was moved into its own folder undersrc/pages/home/report/ReportActionCompose
. Here are all new split out components placed:SendButton.js
: The JSX of the send button was moved into its own component for cleanupSuggestions.js
: Before the mention and emoji suggestions were part of the main composer, and also their state was placed there. The composer itself doesn't have to re-render when we change the suggestion state, so it was moved into its own component.SuggestionMention.js
: Before the mention suggestion were re-rendering when e.g. the emoji suggestions were changing. Now they are decoupled into their own places.SuggestionEmoji.js
: Separate implementation for emoji suggestionsAttachmentPickerWithMenuItems.js
: This contains the options we show when pressing the + in the composer. The options need access to the attachment picker, so they are grouped together. They also had state that's unnecessary to other parts of the composer.ComposerWithSuggestions.js
: Here lives the actual<Composer />
and itsvalue
andselection
state. Only the<Composer />
and the<Suggestions />
need to re-render when any of the two states are changing, hence they are grouped together.SilentCommentUpdater.js
: This components subscribes to the actual draft comment, and fires a side effect for certain conditions. For the other components we don't need the draft comment, so it makes no sense re-rendering these. That's why it was split out into its own component for performance.Another note: Initially I wanted to make separate PRs for each split out component, but: the components were so entangled with each other, that it was only possible to make a full clean up 🍝😅 .
Fixed Issues
$
PROPOSAL:
Tests
From
main
branchmain.mov
From this branch
improved.mov
Offline tests
n/a
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 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)/** comment above it */
this
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)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
Web
Mobile Web - Chrome
Mobile Web - Safari
Desktop
iOS
Android