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

remove Brave from autosuggest and history (again) #7753

Merged
merged 1 commit into from
Mar 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion app/renderer/reducers/urlBarSuggestionsReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,11 @@ const updateUrlSuffix = (state, suggestionList) => {
const generateNewSuggestionsList = (state) => {
const activeFrameKey = state.get('activeFrameKey')
const urlLocation = state.getIn(activeFrameStatePath(state).concat(['navbar', 'urlbar', 'location']))
const sites = appStoreRenderer.state.get('sites')
let sites = appStoreRenderer.state.get('sites')
if (sites) {
// Filter out Brave default newtab sites
sites = sites.filterNot((site) => Immutable.is(site.get('tags'), new Immutable.List(['default'])) && site.get('lastAccessedTime') === 1)
}
const searchResults = state.getIn(activeFrameStatePath(state).concat(['navbar', 'urlbar', 'suggestions', 'searchResults']))
const frameSearchDetail = state.getIn(activeFrameStatePath(state).concat(['navbar', 'urlbar', 'searchDetail']))
const searchDetail = state.get('searchDetail')
Expand Down
2 changes: 1 addition & 1 deletion docs/state.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ AppStore
originalSeed: Array.<number>, // only set for bookmarks that have been synced before a sync profile reset
parentFolderId: number, // set for bookmarks and bookmark folders only
partitionNumber: number, // optionally specifies a specific session
tags: [string], // empty, 'bookmark', 'bookmark-folder', 'pinned', or 'reader'
tags: [string], // empty, 'bookmark', 'bookmark-folder', 'pinned', 'default', or 'reader'
themeColor: string, // CSS compatible color string
title: string
} // folder: folderId; bookmark/history: location + partitionNumber + parentFolderId
Expand Down
19 changes: 8 additions & 11 deletions js/data/newTabData.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
const {getBraveExtUrl} = require('../lib/appUrlUtil')
const iconPath = getBraveExtUrl('img/newtab/defaultTopSitesIcon')

/**
* Let lastAccessedTime be the first-time user see the new tab page
*/
const now = Date.now()
const now = 1

module.exports.pinnedTopSites = [
{
Expand All @@ -17,7 +14,7 @@ module.exports.pinnedTopSites = [
"lastAccessedTime": now,
"location": "https://twitter.com/brave",
"partitionNumber": 0,
"tags": [],
"tags": ['default'],
"themeColor": "rgb(255, 255, 255)",
"title": "Brave Software (@brave) | Twitter"
}
Expand All @@ -30,7 +27,7 @@ module.exports.topSites = [
"lastAccessedTime": now,
"location": "https://twitter.com/brave",
"partitionNumber": 0,
"tags": [],
"tags": ['default'],
"themeColor": "rgb(255, 255, 255)",
"title": "Brave Software (@brave) | Twitter"
}, {
Expand All @@ -39,7 +36,7 @@ module.exports.topSites = [
"lastAccessedTime": now,
"location": "https://www.facebook.com/BraveSoftware/",
"partitionNumber": 0,
"tags": [],
"tags": ['default'],
"themeColor": "rgb(59, 89, 152)",
"title": "Brave Software | Facebook"
}, {
Expand All @@ -48,7 +45,7 @@ module.exports.topSites = [
"lastAccessedTime": now,
"location": "https://www.youtube.com/bravesoftware",
"partitionNumber": 0,
"tags": [],
"tags": ['default'],
"themeColor": "#E62117",
"title": "Brave Browser - YouTube"
}, {
Expand All @@ -57,7 +54,7 @@ module.exports.topSites = [
"lastAccessedTime": now,
"location": "https://brave.com/",
"partitionNumber": 0,
"tags": [],
"tags": ['default'],
"themeColor": "rgb(255, 255, 255)",
"title": "Brave Software | Building a Better Web"
}, {
Expand All @@ -66,7 +63,7 @@ module.exports.topSites = [
"lastAccessedTime": now,
"location": "https://itunes.apple.com/app/brave-web-browser/id1052879175?mt=8",
"partitionNumber": 0,
"tags": [],
"tags": ['default'],
"themeColor": "rgba(255, 255, 255, 1)",
"title": "Brave Web Browser: Fast with built-in adblock on the App Store"
}, {
Expand All @@ -75,7 +72,7 @@ module.exports.topSites = [
"lastAccessedTime": now,
"location": "https://play.google.com/store/apps/details?id=com.brave.browser",
"partitionNumber": 0,
"tags": [],
"tags": ['default'],
"themeColor": "rgb(241, 241, 241)",
"title": "Brave Browser: Fast AdBlock – Apps para Android no Google Play"
}
Expand Down
5 changes: 5 additions & 0 deletions js/state/siteUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,11 @@ module.exports.isHistoryEntry = function (siteDetail) {
if (siteDetail.get('location').startsWith('about:')) {
return false
}
if (Immutable.is(siteDetail.get('tags'), new Immutable.List(['default'])) &&
siteDetail.get('lastAccessedTime') === 1) {
// This is a Brave default newtab site
return false
}
return !!siteDetail.get('lastAccessedTime') && !isBookmarkFolder(siteDetail.get('tags'))
}
return false
Expand Down
5 changes: 5 additions & 0 deletions test/about/historyTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ describe('about:history', function () {
yield addDemoSites(this.app.client)
})

it('does not display Brave default sites', function * () {
yield this.app.client
.waitForVisible('table.sortableTable td.title[data-sort="Brave"]')
.waitForElementCount('td.time', 4)
})
it('displays entries with title as: title or URL', function * () {
yield this.app.client
.waitForVisible('table.sortableTable td.title[data-sort="Brave"]')
Expand Down
10 changes: 7 additions & 3 deletions test/components/urlBarSuggestionsTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,17 @@ describe('urlBarSuggestions', function () {
.waitForElementFocus(urlInput)
})

it('does not show Brave default sites', function * () {
yield this.app.client.ipcSend('shortcut-focus-url')
.waitForElementFocus(urlInput)
.setValue(urlInput, 'twitter')
.waitForElementCount('li.suggestionItem', 1)
})

it('show suggestion when single letter is typed in', function * () {
yield this.app.client.ipcSend('shortcut-focus-url')
.waitForElementFocus(urlInput)
.setInputText(urlInput, 'a')
.waitUntil(function () {
return this.getValue(urlInput).then((val) => val === 'a')
})
.waitForExist(urlBarSuggestions)
})

Expand Down
8 changes: 8 additions & 0 deletions test/unit/state/siteUtilTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -1212,6 +1212,14 @@ describe('siteUtil', function () {
})
assert.equal(siteUtil.isHistoryEntry(siteDetail), false)
})
it('returns false for a brave default site', function () {
const siteDetail = Immutable.fromJS({
location: testUrl1,
tags: ['default'],
lastAccessedTime: 1
})
assert.equal(siteUtil.isHistoryEntry(siteDetail), false)
})
it('returns false if input is falsey', function () {
assert.equal(siteUtil.isHistoryEntry(null), false)
assert.equal(siteUtil.isHistoryEntry(undefined), false)
Expand Down