This repository has been archived by the owner on Dec 11, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 974
Removes all non-primitive types from BookmarksToolbar and BookmarkTool… #9713
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,8 +41,8 @@ const isBookmarkNameValid = (detail, isFolder) => { | |
const title = detail.get('title') || detail.get('customTitle') | ||
const location = detail.get('location') | ||
return isFolder | ||
? (title != null && title.trim().length > 0) | ||
: (location != null && location.trim().length > 0) | ||
? (title != null && title !== 0) && title.trim().length > 0 | ||
: location != null && location.trim().length > 0 | ||
} | ||
|
||
const showOnlyFavicon = () => { | ||
|
@@ -56,24 +56,19 @@ const showFavicon = () => { | |
btbMode === bookmarksToolbarMode.FAVICONS_ONLY | ||
} | ||
|
||
const getDNDBookmarkData = (state, bookmark) => { | ||
const getDNDBookmarkData = (state, bookmarkKey) => { | ||
const data = (state.getIn(['dragData', 'dragOverData', 'draggingOverType']) === dragTypes.BOOKMARK && | ||
state.getIn(['dragData', 'dragOverData'], Immutable.Map())) || Immutable.Map() | ||
|
||
if (data.get('draggingOverKey') == null) { | ||
return Immutable.Map() | ||
} | ||
|
||
// TODO (nejc) this is slow, replace with simple ID check - we need to add id into bookmark object | ||
return (Immutable.is(data.get('draggingOverKey'), bookmark)) ? data : Immutable.Map() | ||
return data.get('draggingOverKey') === bookmarkKey ? data : Immutable.Map() | ||
} | ||
|
||
const getToolbarBookmarks = (state) => { | ||
const sites = state.get('sites', Immutable.List()) | ||
|
||
const noParentItems = siteUtil.getBookmarks(sites) | ||
.sort(siteUtil.siteSort) | ||
.filter((bookmark) => !bookmark.get('parentFolderId')) | ||
.sort(siteUtil.siteSort) | ||
let widthAccountedFor = 0 | ||
const overflowButtonWidth = 25 | ||
const onlyFavicon = showOnlyFavicon() | ||
|
@@ -119,9 +114,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 commentThe 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. I see, makes sense |
||
// Show at most 100 items in the overflow menu | ||
hiddenBookmarks: noParentItems.skip(i).take(100) | ||
hiddenBookmarks: noParentItems.skip(i).take(100).map((item, index) => index).toList() | ||
} | ||
} | ||
|
||
|
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
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
Oops, something went wrong.
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.
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