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

Commit 97fb76e

Browse files
ayumibsclifton
authored andcommitted
Update tab bookmarked state
Fix #8977 Auditors: @bsclifton @bbondy Test Plan: 1. Open https://github.com 2. Bookmark the page 3. Click the middle mouse button to open it in a new tab and switch to the new tab quickly (before it finishes loading) 4. Tab should have bookmark star icon
1 parent b3fc514 commit 97fb76e

File tree

2 files changed

+46
-3
lines changed

2 files changed

+46
-3
lines changed

app/browser/reducers/sitesReducer.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,20 @@ const syncEnabled = () => {
2121
return getSetting(settings.SYNC_ENABLED) === true
2222
}
2323

24+
const updateTabBookmarked = (state, tabValue) => {
25+
if (!tabValue || !tabValue.get('tabId')) {
26+
return state
27+
}
28+
const bookmarked = siteUtil.isLocationBookmarked(state, tabValue.get('url'))
29+
return tabState.updateTabValue(state, tabValue.set('bookmarked', bookmarked))
30+
}
31+
2432
const updateActiveTabBookmarked = (state) => {
2533
const tab = tabState.getActiveTab(state)
2634
if (!tab) {
2735
return state
2836
}
29-
const bookmarked = siteUtil.isLocationBookmarked(state, tab.get('url'))
30-
return tabState.updateTabValue(state, tab.set('bookmarked', bookmarked))
37+
return updateTabBookmarked(state, tab)
3138
}
3239

3340
const sitesReducer = (state, action, immutableAction) => {
@@ -135,6 +142,7 @@ const sitesReducer = (state, action, immutableAction) => {
135142
state = syncUtil.updateSiteCache(state, siteDetail)
136143
}
137144
}
145+
state = updateTabBookmarked(state, action.tabValue)
138146
break
139147
case appConstants.APP_CREATE_TAB_REQUESTED: {
140148
const createProperties = immutableAction.get('createProperties')

test/bookmark-components/bookmarksTest.js

+36-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* global describe, it, before */
1+
/* global describe, it, before, beforeEach */
22

33
const Brave = require('../lib/brave')
44
const Immutable = require('immutable')
@@ -249,6 +249,41 @@ describe('bookmark tests', function () {
249249
})
250250
})
251251

252+
describe('bookmark star button is preserved', function () {
253+
Brave.beforeEach(this)
254+
beforeEach(function * () {
255+
this.page1Url = Brave.server.url('page1.html')
256+
this.page2Url = Brave.server.url('page2.html')
257+
yield setup(this.app.client)
258+
yield this.app.client
259+
.addSite({
260+
location: this.page1Url,
261+
folderId: 1,
262+
parentFolderId: 0,
263+
tags: [siteTags.BOOKMARK]
264+
}, siteTags.BOOKMARK)
265+
})
266+
267+
it('on new active tabs', function * () {
268+
yield this.app.client
269+
.waitForVisible(navigatorNotBookmarked)
270+
.newTab({ url: this.page1Url })
271+
.waitForVisible(navigatorBookmarked)
272+
})
273+
it('on new active tabs', function * () {
274+
yield this.app.client
275+
.waitForVisible(navigatorNotBookmarked)
276+
.newTab({ url: this.page1Url, active: false })
277+
.waitForUrl(this.page1Url)
278+
.tabByIndex(0)
279+
.loadUrl(this.page2Url)
280+
.waitForUrl(this.page2Url)
281+
.windowByUrl(Brave.browserWindowUrl)
282+
.ipcSend('shortcut-next-tab')
283+
.waitForVisible(navigatorBookmarked)
284+
})
285+
})
286+
252287
describe('menu behavior', function () {
253288
Brave.beforeAll(this)
254289

0 commit comments

Comments
 (0)