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

Commit

Permalink
Kepp bookmark toolbar's context menu and folder of bookmark manager i…
Browse files Browse the repository at this point in the history
…n order

Auditors: @bbondy

Test Plan:
1. Folder in bookmark manager should be the same order as bookmark toolbar
2. Bookmark toolbar's context menu should be the same order as bookmark manager
  • Loading branch information
darkdh committed Feb 3, 2017
1 parent bbede6c commit 1d936db
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
11 changes: 5 additions & 6 deletions app/renderer/components/bookmarksToolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ class BookmarksToolbar extends ImmutableComponent {
contextMenus.onShowBookmarkFolderMenu(this.bookmarks, bookmark, this.activeFrame, e)
}
updateBookmarkData (props) {
this.bookmarks = siteUtil.getBookmarks(props.sites)
this.bookmarks = siteUtil.getBookmarks(props.sites).toList().sort(siteUtil.siteSort)

const noParentItems = this.bookmarks
.filter((bookmark) => !bookmark.get('parentFolderId'))
Expand All @@ -319,18 +319,17 @@ class BookmarksToolbar extends ImmutableComponent {

// Loop through until we fill up the entire bookmark toolbar width
let i
let noParentItemsList = noParentItems.toList()
for (i = 0; i < noParentItemsList.size; i++) {
for (i = 0; i < noParentItems.size; i++) {
let iconWidth = props.showFavicon ? iconSize : 0
// font-awesome file icons are 3px smaller
if (props.showFavicon && !noParentItemsList.getIn([i, 'folderId']) && !noParentItemsList.getIn([i, 'favicon'])) {
if (props.showFavicon && !noParentItems.getIn([i, 'folderId']) && !noParentItems.getIn([i, 'favicon'])) {
iconWidth -= 3
}
const chevronWidth = props.showFavicon && noParentItemsList.getIn([i, 'folderId']) ? this.chevronWidth : 0
const chevronWidth = props.showFavicon && noParentItems.getIn([i, 'folderId']) ? this.chevronWidth : 0
if (props.showFavicon && props.showOnlyFavicon) {
widthAccountedFor += this.padding + iconWidth + chevronWidth
} else {
const text = noParentItemsList.getIn([i, 'customTitle']) || noParentItemsList.getIn([i, 'title']) || noParentItemsList.getIn([i, 'location'])
const text = noParentItems.getIn([i, 'customTitle']) || noParentItems.getIn([i, 'title']) || noParentItems.getIn([i, 'location'])
widthAccountedFor += Math.min(calculateTextWidth(text, `${this.fontSize} ${this.fontFamily}`) + this.padding + iconWidth + chevronWidth, this.maxWidth)
}
widthAccountedFor += margin
Expand Down
2 changes: 1 addition & 1 deletion js/components/frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class Frame extends ImmutableComponent {
!Immutable.is(prevProps.bookmarkFolders, this.props.bookmarkFolders)) {
this.webview.send(messages.BOOKMARKS_UPDATED, {
bookmarks: this.props.bookmarks.toList().sort(siteUtil.siteSort).toJS(),
bookmarkFolders: this.props.bookmarkFolders.toJS()
bookmarkFolders: this.props.bookmarkFolders.toList().sort(siteUtil.siteSort).toJS()
})
}
} else if (location === 'about:history') {
Expand Down

0 comments on commit 1d936db

Please sign in to comment.