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

Commit

Permalink
Avoid imported bookmarks on new tab page
Browse files Browse the repository at this point in the history
Fix #6217

Auditors: @bsclifton
  • Loading branch information
cezaraugusto authored and bsclifton committed Jan 24, 2017
1 parent 851358d commit 4b5d79e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/common/state/aboutNewTabState.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ const getTopSites = (state) => {
// remove folders; sort by visit count; enforce a max limit
const sites = (state.get('sites') || new Immutable.List())
.filter((site) => !siteUtil.isFolder(site))
.filter((site) => !siteUtil.isImportedBookmark(site))
.filter((site) => !isSourceAboutUrl(site.get('location')))
.sort(sortCountDescending)
.slice(0, aboutNewTabMaxEntries)
Expand Down
9 changes: 9 additions & 0 deletions js/state/siteUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,15 @@ module.exports.isFolder = function (siteDetail) {
return false
}

/**
* Determines if the site detail is an imported bookmark.
* @param siteDetail The site detail to check.
* @return true if the site detail is a folder.
*/
module.exports.isImportedBookmark = function (siteDetail) {
return siteDetail.get('lastAccessedTime') === 0
}

/**
* Determines if the site detail is a history entry.
* @param siteDetail The site detail to check.
Expand Down
11 changes: 11 additions & 0 deletions test/unit/app/common/state/aboutNewTabStateTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ describe('aboutNewTabState', function () {
const site5 = Immutable.fromJS({
location: 'https://example4.com', title: 'sample 5', parentFolderId: 0, count: 23, lastAccessedTime: 456
})
const importedBookmark1 = Immutable.fromJS({
location: 'https://example6.com', title: 'sample 6', parentFolderId: 0, count: 23, lastAccessedTime: 0
})
const folder1 = Immutable.fromJS({
customTitle: 'folder1', parentFolderId: 0, tags: [siteTags.BOOKMARK_FOLDER]
})
Expand All @@ -69,6 +72,14 @@ describe('aboutNewTabState', function () {
assert.deepEqual(actualState.getIn(['about', 'newtab', 'sites']).toJS(), expectedSites.toJS())
})

it('does not include imported bookmarks (lastAccessedTime === 0)', function () {
const stateWithSites = defaultAppState.set('sites',
Immutable.List().push(site1).push(importedBookmark1))
const expectedSites = Immutable.List().push(site1)
const actualState = aboutNewTabState.setSites(stateWithSites)
assert.deepEqual(actualState.getIn(['about', 'newtab', 'sites']).toJS(), expectedSites.toJS())
})

it('sorts results by `count` DESC', function () {
const stateWithSites = defaultAppState.set('sites',
Immutable.List().push(site1).push(site2).push(site3).push(site4))
Expand Down

0 comments on commit 4b5d79e

Please sign in to comment.