Skip to content
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

Fix Desktop - CMD + K is slow and laggy #3601 #3760

Merged

Conversation

Looxor
Copy link
Contributor

@Looxor Looxor commented Jun 25, 2021

Details

  1. src/pages/SearchPage.js
  • added filterAdapter
  • added getCustomHeaderMessage
  • removed onChangeText
  • added conditional render using didScreenTransitionEnd
  1. src/components/OptionsSelector.js
  • removed props.onChangeText
  • added filterAdapter
  • added getCustomHeaderMessage

Fixed Issues

$ #3601

Tests

  1. While using e.cash use the cmd+k command
  2. Type on the search field

QA Steps

  1. While using e.cash use the cmd+k command
  2. Type on the search field

Tested On

  • Web
  • Mobile Web
  • Desktop
  • iOS
  • Android

Screenshots

Web

Mobile Web

Desktop

expensify-fix-result.mp4

iOS

Android

I have read the CLA Document and I hereby sign the CLA.

@Looxor Looxor requested a review from a team as a code owner June 25, 2021 18:32
@github-actions
Copy link
Contributor

github-actions bot commented Jun 25, 2021

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@MelvinBot MelvinBot requested review from thienlnam and removed request for a team June 25, 2021 18:32
@Looxor
Copy link
Contributor Author

Looxor commented Jun 28, 2021

I have read the CLA Document and I hereby sign the CLA.

Comment on lines 15 to 16
filterAdapter: PropTypes.func,
getCustomHeaderMessage: PropTypes.func,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each prop needs a comment

@@ -207,12 +214,12 @@ class OptionsSelector extends Component {
ref={el => this.list = el}
optionHoveredStyle={styles.hoveredComponentBG}
onSelectRow={this.selectRow}
sections={this.props.sections}
sections={this.state.sections || this.props.sections}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we just initialize the state with the sections from props?

focusedIndex={this.state.focusedIndex}
selectedOptions={this.props.selectedOptions}
canSelectMultipleOptions={this.props.canSelectMultipleOptions}
hideSectionHeaders={this.props.hideSectionHeaders}
headerMessage={this.props.headerMessage}
headerMessage={headerMessage}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't need a separate variable for this, let's just put this.props.getCustomHeaderMessage(this.searchValue) here

@@ -62,11 +59,10 @@ class SearchPage extends Component {
constructor(props) {
super(props);

Timing.start(CONST.TIMING.SEARCH_RENDER);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We still want the Timing I believe, can we get this added back but maybe put where it belongs now?

Comment on lines 145 to 146
// eslint-disable-next-line no-console
console.log('lazyLoad', this.state.readyToLoad);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't still need this log line

Comment on lines 176 to 180
? (
<Text>
...
</Text>
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We definitely don't want to show the ... text when the screen is loading, we should either show a loading indicator here or just leave it like how it was before

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed log again.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated everything you asked.

@Looxor
Copy link
Contributor Author

Looxor commented Jun 28, 2021

I updated everything as you asked.

Comment on lines 1 to 3
Looxor
MyNameIsJin08011952l.
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't think you want this file in here

Copy link
Contributor Author

@Looxor Looxor Jun 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed it.
It was made by my mistake when I create a token file by reading a tutorial of my friend. Sorry.

Comment on lines 15 to 18
/** Function to get a filtered result as list */
filterAdapter: PropTypes.func,
/** FUnction to get header message from parent component */
getCustomHeaderMessage: PropTypes.func,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New line before each comment, also a typo with FUnction

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I added them.

Comment on lines 177 to 179
!didScreenTransitionEnd
? null
: (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should just make this {({didScreenTransitionEnd}) => ( and remove the null conditional

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I removed it.

}

componentDidMount() {
Timing.end(CONST.TIMING.SEARCH_RENDER);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The timing isn't getting ended so this will just be an infinite timer

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I added it. Sorry for forgetting.

/** Function to get a filtered result as list */
filterAdapter: PropTypes.func,

/** FUnction to get header message from parent component */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo with FUnction

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, updated. Sorry for typo

Comment on lines 81 to 83
this.recentReports = recentReports;
this.personalDetails = personalDetails;
this.userToInvite = userToInvite;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't these need to be left in state so this can re-render with changes to these values?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't know that the SearchPage needs to re-render when updating props, but just found Onyx component wrapper.
Ok, I will change that to use this.props. (recentReports, personDetails, userToInvite)

* @param {String} searchValue
* @returns {Array}
*/
filterAdapter(searchValue) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confused at why this is called filterAdapter

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding this, honestly, I was also confused because I am not sure which type of design pattern is preferred in this project.
I renamed it to searchSections.
But, if it is not good, can you please recommend one?

Comment on lines 105 to 109
* @returns {Array}
*/
getSections() {
return this.filterAdapter('');
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you need to rename this method / update the comment now

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I renamed it to searchSections.

@Looxor
Copy link
Contributor Author

Looxor commented Jun 29, 2021

Thank you for your time to fix my mistakes on updating codes.

Copy link
Contributor

@thienlnam thienlnam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks for making all these changes! It's looking good

@thienlnam thienlnam merged commit 7299d6c into Expensify:main Jun 29, 2021
@OSBotify
Copy link
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify
Copy link
Contributor

🚀 Deployed to staging in version: 1.0.74-1🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

Copy link
Member

@parasharrajat parasharrajat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR has caused a regression #3818.

<OptionsSelector
sections={sections}
onSelectRow={this.selectReport}
searchSections={this.searchSections}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This prop needs to be passed to other pages where this component is used. Otherwise, Search will not work there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, do you mean to use this.props.sections?
It makes multiple-rendering as I explained here.
#3601 (comment)

hideSectionHeaders
hideAdditionalOptionStates
showTitleTooltip
didScreenTransitionEnd && (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why didScreenTransitionEnd was moved up? I mean we didn't want to hide the header of the page behind the loader.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I put didScreenTransitionEnd, I found that CMD+K is much faster.
But, if needed, I will put it back.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants