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

Commit 181c997

Browse files
authored
Merge pull request #7753 from brave/fix/7655
remove Brave from autosuggest and history (again)
2 parents 067ca56 + ebfc338 commit 181c997

File tree

7 files changed

+39
-16
lines changed

7 files changed

+39
-16
lines changed

app/renderer/reducers/urlBarSuggestionsReducer.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,11 @@ const updateUrlSuffix = (state, suggestionList) => {
125125
const generateNewSuggestionsList = (state) => {
126126
const activeFrameKey = state.get('activeFrameKey')
127127
const urlLocation = state.getIn(activeFrameStatePath(state).concat(['navbar', 'urlbar', 'location']))
128-
const sites = appStoreRenderer.state.get('sites')
128+
let sites = appStoreRenderer.state.get('sites')
129+
if (sites) {
130+
// Filter out Brave default newtab sites
131+
sites = sites.filterNot((site) => Immutable.is(site.get('tags'), new Immutable.List(['default'])) && site.get('lastAccessedTime') === 1)
132+
}
129133
const searchResults = state.getIn(activeFrameStatePath(state).concat(['navbar', 'urlbar', 'suggestions', 'searchResults']))
130134
const frameSearchDetail = state.getIn(activeFrameStatePath(state).concat(['navbar', 'urlbar', 'searchDetail']))
131135
const searchDetail = state.get('searchDetail')

docs/state.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ AppStore
232232
originalSeed: Array.<number>, // only set for bookmarks that have been synced before a sync profile reset
233233
parentFolderId: number, // set for bookmarks and bookmark folders only
234234
partitionNumber: number, // optionally specifies a specific session
235-
tags: [string], // empty, 'bookmark', 'bookmark-folder', 'pinned', or 'reader'
235+
tags: [string], // empty, 'bookmark', 'bookmark-folder', 'pinned', 'default', or 'reader'
236236
themeColor: string, // CSS compatible color string
237237
title: string
238238
} // folder: folderId; bookmark/history: location + partitionNumber + parentFolderId

js/data/newTabData.js

+8-11
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@
55
const {getBraveExtUrl} = require('../lib/appUrlUtil')
66
const iconPath = getBraveExtUrl('img/newtab/defaultTopSitesIcon')
77

8-
/**
9-
* Let lastAccessedTime be the first-time user see the new tab page
10-
*/
11-
const now = Date.now()
8+
const now = 1
129

1310
module.exports.pinnedTopSites = [
1411
{
@@ -17,7 +14,7 @@ module.exports.pinnedTopSites = [
1714
"lastAccessedTime": now,
1815
"location": "https://twitter.com/brave",
1916
"partitionNumber": 0,
20-
"tags": [],
17+
"tags": ['default'],
2118
"themeColor": "rgb(255, 255, 255)",
2219
"title": "Brave Software (@brave) | Twitter"
2320
}
@@ -30,7 +27,7 @@ module.exports.topSites = [
3027
"lastAccessedTime": now,
3128
"location": "https://twitter.com/brave",
3229
"partitionNumber": 0,
33-
"tags": [],
30+
"tags": ['default'],
3431
"themeColor": "rgb(255, 255, 255)",
3532
"title": "Brave Software (@brave) | Twitter"
3633
}, {
@@ -39,7 +36,7 @@ module.exports.topSites = [
3936
"lastAccessedTime": now,
4037
"location": "https://www.facebook.com/BraveSoftware/",
4138
"partitionNumber": 0,
42-
"tags": [],
39+
"tags": ['default'],
4340
"themeColor": "rgb(59, 89, 152)",
4441
"title": "Brave Software | Facebook"
4542
}, {
@@ -48,7 +45,7 @@ module.exports.topSites = [
4845
"lastAccessedTime": now,
4946
"location": "https://www.youtube.com/bravesoftware",
5047
"partitionNumber": 0,
51-
"tags": [],
48+
"tags": ['default'],
5249
"themeColor": "#E62117",
5350
"title": "Brave Browser - YouTube"
5451
}, {
@@ -57,7 +54,7 @@ module.exports.topSites = [
5754
"lastAccessedTime": now,
5855
"location": "https://brave.com/",
5956
"partitionNumber": 0,
60-
"tags": [],
57+
"tags": ['default'],
6158
"themeColor": "rgb(255, 255, 255)",
6259
"title": "Brave Software | Building a Better Web"
6360
}, {
@@ -66,7 +63,7 @@ module.exports.topSites = [
6663
"lastAccessedTime": now,
6764
"location": "https://itunes.apple.com/app/brave-web-browser/id1052879175?mt=8",
6865
"partitionNumber": 0,
69-
"tags": [],
66+
"tags": ['default'],
7067
"themeColor": "rgba(255, 255, 255, 1)",
7168
"title": "Brave Web Browser: Fast with built-in adblock on the App Store"
7269
}, {
@@ -75,7 +72,7 @@ module.exports.topSites = [
7572
"lastAccessedTime": now,
7673
"location": "https://play.google.com/store/apps/details?id=com.brave.browser",
7774
"partitionNumber": 0,
78-
"tags": [],
75+
"tags": ['default'],
7976
"themeColor": "rgb(241, 241, 241)",
8077
"title": "Brave Browser: Fast AdBlock – Apps para Android no Google Play"
8178
}

js/state/siteUtil.js

+5
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,11 @@ module.exports.isHistoryEntry = function (siteDetail) {
580580
if (siteDetail.get('location').startsWith('about:')) {
581581
return false
582582
}
583+
if (Immutable.is(siteDetail.get('tags'), new Immutable.List(['default'])) &&
584+
siteDetail.get('lastAccessedTime') === 1) {
585+
// This is a Brave default newtab site
586+
return false
587+
}
583588
return !!siteDetail.get('lastAccessedTime') && !isBookmarkFolder(siteDetail.get('tags'))
584589
}
585590
return false

test/about/historyTest.js

+5
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ describe('about:history', function () {
4848
yield addDemoSites(this.app.client)
4949
})
5050

51+
it('does not display Brave default sites', function * () {
52+
yield this.app.client
53+
.waitForVisible('table.sortableTable td.title[data-sort="Brave"]')
54+
.waitForElementCount('td.time', 4)
55+
})
5156
it('displays entries with title as: title or URL', function * () {
5257
yield this.app.client
5358
.waitForVisible('table.sortableTable td.title[data-sort="Brave"]')

test/components/urlBarSuggestionsTest.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,17 @@ describe('urlBarSuggestions', function () {
3737
.waitForElementFocus(urlInput)
3838
})
3939

40+
it('does not show Brave default sites', function * () {
41+
yield this.app.client.ipcSend('shortcut-focus-url')
42+
.waitForElementFocus(urlInput)
43+
.setValue(urlInput, 'twitter')
44+
.waitForElementCount('li.suggestionItem', 1)
45+
})
46+
4047
it('show suggestion when single letter is typed in', function * () {
4148
yield this.app.client.ipcSend('shortcut-focus-url')
4249
.waitForElementFocus(urlInput)
4350
.setInputText(urlInput, 'a')
44-
.waitUntil(function () {
45-
return this.getValue(urlInput).then((val) => val === 'a')
46-
})
4751
.waitForExist(urlBarSuggestions)
4852
})
4953

test/unit/state/siteUtilTest.js

+8
Original file line numberDiff line numberDiff line change
@@ -1212,6 +1212,14 @@ describe('siteUtil', function () {
12121212
})
12131213
assert.equal(siteUtil.isHistoryEntry(siteDetail), false)
12141214
})
1215+
it('returns false for a brave default site', function () {
1216+
const siteDetail = Immutable.fromJS({
1217+
location: testUrl1,
1218+
tags: ['default'],
1219+
lastAccessedTime: 1
1220+
})
1221+
assert.equal(siteUtil.isHistoryEntry(siteDetail), false)
1222+
})
12151223
it('returns false if input is falsey', function () {
12161224
assert.equal(siteUtil.isHistoryEntry(null), false)
12171225
assert.equal(siteUtil.isHistoryEntry(undefined), false)

0 commit comments

Comments
 (0)