Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Improves perf of bookmark hanger #9710

Merged
merged 1 commit into from
Jul 11, 2017

Conversation

NejcZdovc
Copy link
Contributor

@NejcZdovc NejcZdovc commented Jun 26, 2017

Submitter Checklist:

  • Submitted a ticket for my issue if one did not already exist.
  • Used Github auto-closing keywords in the commit message.
  • Added/updated tests for this change (for new code or code which already has tests).
  • Ran git rebase -i to squash commits (if needed).
  • Tagged reviewers and labelled the pull request as needed.

Resolves #9674
Possible fix for #9602
Fix #5314
Fix #5508
Fix #4978

Auditors: @bsclifton

  1. Bookmark
  • try to add a bookmark
  • try to add a bookmark, but into the second level folder
  1. Bookmark folder
  • try to add a bookmark folder
  1. Bookmark
  • try to edit a bookmark
  1. Bookmark folder
  • try to add a bookmark folder
  1. Bookmark
  • try to remove a bookmark
  1. Bookmark folder
  • try to remove a bookmark folder
  1. Bookmark
  • try to add a bookmark into a folder (with a right click on a folder)
  • folder should be preselected
  1. Bookmark folder
  • try to add a bookmark folder into a folder (with a right click on a folder)
  • folder should be preselected
  1. Navigation bar
  • try to bookmark a page via navigation bar star
  1. Navigation bar
  • try to edit a bookmark via navigation bar star
  1. Bookmark manager
  • try to add a bookmark folder from a bookmark manager (list, folder tree and button)
  1. Bookmark manager
  • try to add a bookmark from a bookmark manager (list, folder tree and button)
  1. Bookmark manager
  • try to edit a bookmark from a bookmark manager (list and folder tree)
  1. Bookmark manager
  • try to edit a bookmark folder from a bookmark manager (list and folder tree)
  1. Perf
  • have a lot of bookmarks (1k +)
  • try to add a bookmark with clicking on the star
  1. Perf
  • have a lot of bookmarks (1k +)
  • right click on bookmarks toolbar and click Add folder
  1. Bookmark link
  • try to bookmark a link (right click on a link in the page)

Reviewer Checklist:

Tests

  • Adequate test coverage exists to prevent regressions
  • Tests should be independent and work correctly when run individually or as a suite ref
  • New files have MPL2 license header

@NejcZdovc NejcZdovc added this to the 0.18.x (Developer Channel) milestone Jun 26, 2017
@NejcZdovc NejcZdovc self-assigned this Jun 26, 2017
@NejcZdovc NejcZdovc requested a review from bsclifton June 26, 2017 08:09
@NejcZdovc
Copy link
Contributor Author

NejcZdovc commented Jun 26, 2017

Some comparison of the merge props compute time with @bsclifton's exported file:

Before this PR:
screen shot 2017-06-26 at 09 59 43

After this PR:
screen shot 2017-06-26 at 10 01 53

Copy link
Member

@bsclifton bsclifton left a comment

Choose a reason for hiding this comment

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

This is better for sure- but one of the main problems seems to be that every keydown is triggering a window action (which I think is unnecessary). Also, doing the punycode on each keystroke is expensive

@NejcZdovc
Copy link
Contributor Author

@bsclifton what would you suggest?

We have couple of options.

  1. debounce
  2. blur event
  3. save only when you click on save button
  4. ...

@bsclifton
Copy link
Member

@NejcZdovc the save (or remove) when you click the button is the best option, IMO. But we'd still need a handler for if the button should be enabled or not (ex: is the length > 0 for title)

@NejcZdovc NejcZdovc changed the base branch from 0.18.x to master July 4, 2017 13:32
@NejcZdovc NejcZdovc modified the milestones: 0.19.x (Developer Channel), 0.18.x (Beta Channel) Jul 4, 2017
@NejcZdovc NejcZdovc force-pushed the hotfix/#9674-bookmark branch 13 times, most recently from 3f0712f to c27d482 Compare July 6, 2017 08:35
@NejcZdovc
Copy link
Contributor Author

@bsclifton ok, now this PR is finally finished. I did complete rewrite of adding/editing bookmarks.

@NejcZdovc NejcZdovc force-pushed the hotfix/#9674-bookmark branch 5 times, most recently from c0372f1 to 21e2b13 Compare July 11, 2017 06:15
for (let i = 0; i < resultSize; i++) {
const site = results.get(i)
if (site.get('folderId') === folderId) {
return
Copy link
Contributor Author

@NejcZdovc NejcZdovc Jul 11, 2017

Choose a reason for hiding this comment

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

Please change this from return to continue

Copy link
Member

Choose a reason for hiding this comment

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

done 😄

case appConstants.APP_ADD_BOOKMARK:
case appConstants.APP_EDIT_BOOKMARK:
{
const isSyncEnabled = syncEnabled()
Copy link
Member

Choose a reason for hiding this comment

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

nitpick for this section- it has enough logic and branches (if/else) that it would be nice to pull it out to a function so that it can be easily tested

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This section is fully covered with tests. I wouldn't move it into the function that is exportable. What we can do is move this block into the new function but keep it in the same file for internal use.

}

onClose () {
windowActions.setBookmarkDetail()
windowActions.onBookmarkClose()
Copy link
Member

Choose a reason for hiding this comment

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

So much nicer! Thanks for taking the time to properly name these 😄

@@ -171,7 +171,7 @@ Notifies that a tab has been closed



### addSite(siteDetail, tag, originalSiteDetail, destinationIsParent, skipSync)
### addSite(siteDetail, tag, skipSync)
Copy link
Member

Choose a reason for hiding this comment

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

❤️

for (let i = 0; i < resultSize; i++) {
const site = results.get(i)
if (site.get('folderId') === folderId) {
return
Copy link
Member

Choose a reason for hiding this comment

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

done 😄

@NejcZdovc NejcZdovc force-pushed the hotfix/#9674-bookmark branch 2 times, most recently from 40dbd62 to 8a38142 Compare July 11, 2017 07:28
Resolves brave#9674

Auditors: @bsclifton

Test Plan:
- have a lot of bookmarks (1k +)
- try to add a bookmark with clicking on the star
Copy link
Member

@bsclifton bsclifton left a comment

Choose a reason for hiding this comment

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

I found a few bugs which you had fixed @NejcZdovc 😄 Great job on this PR. Much needed overhaul on some of the older code and it makes a huge positive impact when users have a decent number of bookmarks. ++++!

@NejcZdovc
Copy link
Contributor Author

Thank you very much for this late night review 😃

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.