diff --git a/app/common/state/aboutNewTabState.js b/app/common/state/aboutNewTabState.js index 3d46147de5c..d94ba97f3fd 100644 --- a/app/common/state/aboutNewTabState.js +++ b/app/common/state/aboutNewTabState.js @@ -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) diff --git a/js/state/siteUtil.js b/js/state/siteUtil.js index b85aaaad1ae..dca0dba7763 100644 --- a/js/state/siteUtil.js +++ b/js/state/siteUtil.js @@ -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. diff --git a/test/unit/app/common/state/aboutNewTabStateTest.js b/test/unit/app/common/state/aboutNewTabStateTest.js index 9349f47907a..c40351e9aa0 100644 --- a/test/unit/app/common/state/aboutNewTabStateTest.js +++ b/test/unit/app/common/state/aboutNewTabStateTest.js @@ -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] }) @@ -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))