-
Notifications
You must be signed in to change notification settings - Fork 975
Removes all non-primitive types from BookmarksToolbar and BookmarkTool… #9713
Conversation
7178a74
to
a873a16
Compare
e902032
to
147aba4
Compare
.filter((bookmark) => !bookmark.get('parentFolderId')) | ||
.sort(siteUtil.siteSort) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
++ on filter before sort
@@ -119,9 +119,9 @@ const getToolbarBookmarks = (state) => { | |||
} | |||
|
|||
return { | |||
visibleBookmarks: noParentItems.take(i), | |||
visibleBookmarks: noParentItems.take(i).map((item, index) => index).toList(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure I understand this change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of sending the whole object we are sending only keys. So we have list of keys and this way we are not triggering re-renders. We send this key to the child components which gets the whole object from the state.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, makes sense
const {SWITCH_TO_NEW_TABS} = require('../constants/settings') | ||
const getSetting = require('../settings').getSetting | ||
|
||
const bookmarkActions = { | ||
openBookmarksInFolder: function (allBookmarkItems, folderDetail) { | ||
openBookmarksInFolder: function (folderDetail) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this one should also be converted to an action. Not sure why this is called bookmarkActions
, probably just some legacy reason because it's not an action the way we define them now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can probably dump this whole file, make a real action and move the logic to the reducer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that we need to convert this, but not sure if this PR is the right one to do it in. One thing that we also need to discuss is how can we call other actions inside the reducers. One case that I had was calling an actions that was then handled in multiple reducers. So we need to define this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should not be calling actions from reducers, that breaks the uni-directional flow that is the whole point of flux/redux. The only time we are doing that now is for some special cases in the windowStore and maybe a few legacy calls. If you have a specific example to look at we can talk about options
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as far as converting it goes, this is just like the others. It is accessing appStoreRenderer
and that is problematic. Why is this any different than the others that you already converted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure that that's enough. So if you check out createTabRequested
you will see that we have two places where we call APP_CREATE_TAB_REQUESTED
.
Now if instead of calling this app actions I just do tabs.create
some logic will be lost, which would be called otherwise. This is the main reason why I keep using actions, because they are used in different places and I could regress some logic if I just pick one. What I don't want to do is duplicating a code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the handler in sitesReducer should be changed to APP_TAB_CREATED
. APP_CREATE_TAB_REQUESTED
is a temporary workaround until we move things to the browser process so nothing else should handle it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in any case if tabs.create
doesn't encapsulate all the logic for creating a tab then we need to fix that because the api is not useful if it can only be called through APP_CREATE_TAB_REQUESTED
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for instance activateIfOpen
shouldn't be an action property because it always applies to specific urls
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on our conversation yesterday I would suggest that we merged this PR. This file bookmarkActions.js
was not really the focus in this PR, so I would suggest that we create a follow up where we would refactor only this file.
e.stopPropagation() | ||
} | ||
|
||
windowActions.onShowBookmarkFolderMenu(this.props.bookmarkKey, left, top) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add a TODO to merge setBookmarksToolbarSelectedFolderId
into onShowBookmarkFolderMenu
. We should never call more than one action at a time
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
icon: showFavicon ? site.get('favicon') : undefined, | ||
faIcon, | ||
contextMenu: function (e) { | ||
onSiteDetailMenu(state, item[0], e) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is supposed to be windowActions. onSiteDetailMenu
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a test that covers this? Looks like it should be failing if there is
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
47f9dca
to
642db43
Compare
642db43
to
8aff1dc
Compare
8aff1dc
to
081ddc8
Compare
081ddc8
to
d49b5ca
Compare
d49b5ca
to
1466694
Compare
re-run |
9439534
to
3fa0af0
Compare
…barButton Resolves brave#9712 Auditors: @bsclifton Test Plan:
3fa0af0
to
88f5188
Compare
what's the status of this? currently UI lag is immense in master, encumbering other performance work. i'm really looking forward to this patch! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
++ with follow-up from action discussion
Removes all non-primitive types from BookmarksToolbar and BookmarkTool…
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
++
@@ -89,6 +101,414 @@ const onTabPageMenu = function (state, action) { | |||
tabPageMenu.popup(getCurrentWindow()) | |||
} | |||
|
|||
const openInNewTabMenuItem = (url, isPrivate, partitionNumber, openerTabId) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Each of these menu types should be in a file (I'd suggest commonMenu- see https://github.com/brave/browser-laptop/blob/2bd7726b6d6ea83f41fbebdfab6b4141f8a5a78b/app/common/commonMenu.js). This would make it easy to unit test each method. A quick example of something easy to test: you can check each method that's exported to make sure each has a label field that called locale.translation()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be great in a follow up 😄 Everything else looks good
…barButton
Submitter Checklist:
git rebase -i
to squash commits (if needed).Resolves #9712
Auditors: @bsclifton
Test plan:
Note: Reordering in context menu is not working. Will create issue for it.
Reviewer Checklist:
Tests