Skip to content

Commit

Permalink
Revert "Fix deleting history entry"
Browse files Browse the repository at this point in the history
This reverts commit 67aef34.

Will be recommitted once refactor sites-split work is merged.
  • Loading branch information
diracdeltas authored and dfperry5 committed Aug 18, 2017
1 parent a732ed5 commit 9723563
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 33 deletions.
13 changes: 3 additions & 10 deletions app/browser/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -673,15 +673,8 @@ const doAction = (state, action) => {
}
case windowConstants.WINDOW_CLEAR_CLOSED_FRAMES:
{
if (!action.location) {
closedFrames = new Immutable.OrderedMap()
lastClosedUrl = null
} else {
closedFrames = closedFrames.delete(action.location)
if (lastClosedUrl === action.location) {
lastClosedUrl = null
}
}
closedFrames = new Immutable.OrderedMap()
lastClosedUrl = null
updateRecentlyClosedMenuItems(state)
break
}
Expand Down Expand Up @@ -727,7 +720,7 @@ const doAction = (state, action) => {
}
case appConstants.APP_REMOVE_SITE:
{
if (!action.tag || action.tag === siteTags.BOOKMARK || action.tag === siteTags.BOOKMARK_FOLDER) {
if (action.tag === siteTags.BOOKMARK || action.tag === siteTags.BOOKMARK_FOLDER) {
createMenu(state)
}
break
Expand Down
7 changes: 2 additions & 5 deletions js/actions/windowActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,10 @@ const windowActions = {

/**
* Dispatches a message to the store to clear closed frames
* @param {string=} location - If specified, only clear frames with this
* location.
*/
clearClosedFrames: function (location) {
clearClosedFrames: function () {
dispatch({
actionType: windowConstants.WINDOW_CLEAR_CLOSED_FRAMES,
location
actionType: windowConstants.WINDOW_CLEAR_CLOSED_FRAMES
})
},

Expand Down
4 changes: 2 additions & 2 deletions js/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ ipc.on(messages.APP_STATE_CHANGE, (e, action) => {
: appStoreRenderer.state = Immutable.fromJS(action.state)
})

ipc.on(messages.CLEAR_CLOSED_FRAMES, (e, location) => {
windowActions.clearClosedFrames(location)
ipc.on(messages.CLEAR_CLOSED_FRAMES, () => {
windowActions.clearClosedFrames()
})

window.addEventListener('beforeunload', function (e) {
Expand Down
5 changes: 0 additions & 5 deletions js/state/siteUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -417,11 +417,6 @@ module.exports.removeSite = function (state, siteDetail, tag, reorder = true, sy
site = site.set('tags', tags)
return state.setIn(stateKey, site)
} else {
const siteDetailTags = siteDetail.get('tags')
if (!tag && (!siteDetailTags || siteDetailTags.size === 0)) {
// Delete the site from history
return state.deleteIn(stateKey)
}
site = site.set('lastAccessedTime', undefined)
return state.setIn(stateKey, site)
}
Expand Down
3 changes: 0 additions & 3 deletions js/stores/appStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -472,9 +472,6 @@ const handleAppAction = (action) => {
case appConstants.APP_REMOVE_SITE:
calculateTopSites(true)
appState = aboutHistoryState.setHistory(appState, action)
if (!action.tag && siteUtil.isHistoryEntry(action.siteDetail)) {
BrowserWindow.getAllWindows().forEach((wnd) => wnd.webContents.send(messages.CLEAR_CLOSED_FRAMES, action.siteDetail.get('location')))
}
break
case appConstants.APP_SET_DATA_FILE_ETAG:
appState = appState.setIn([action.resourceName, 'etag'], action.etag)
Expand Down
7 changes: 1 addition & 6 deletions js/stores/windowStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -369,12 +369,7 @@ const doAction = (action) => {
}
break
case windowConstants.WINDOW_CLEAR_CLOSED_FRAMES:
if (!action.location) {
windowState = windowState.set('closedFrames', new Immutable.List())
} else {
windowState = windowState.set('closedFrames',
windowState.get('closedFrames').filterNot((frame) => frame.get('location') === action.location))
}
windowState = windowState.set('closedFrames', new Immutable.List())
break
case windowConstants.WINDOW_SET_PREVIEW_FRAME:
windowState = frameStateUtil.setPreviewFrameKey(windowState, action.frameKey, true)
Expand Down
3 changes: 2 additions & 1 deletion test/unit/app/browser/reducers/sitesReducerTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ describe('sitesReducerTest', function () {
let newState = sitesReducer(state, action)
action.actionType = appConstants.APP_REMOVE_SITE
newState = sitesReducer(newState, action).toJS()
assert.equal(Object.keys(newState.sites).length, 0)
assert.equal(Object.keys(newState.sites).length, 1)
assert.equal(Object.keys(newState.sites)[0].lastAccessedTime, undefined)
})
})
describe('APP_MOVE_SITE', function () {
Expand Down
8 changes: 7 additions & 1 deletion test/unit/state/siteUtilTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,13 @@ describe('siteUtil', function () {
location: testUrl1,
lastAccessedTime: 123
}
const expectedSites = {}
const expectedSites = {
'https://brave.com/|0|0': {
tags: [],
location: testUrl1,
lastAccessedTime: undefined
}
}
const siteKey = siteUtil.getSiteKey(Immutable.fromJS(siteDetail))
let sites = {}
sites[siteKey] = siteDetail
Expand Down

0 comments on commit 9723563

Please sign in to comment.