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

Commit

Permalink
Merge pull request #3501 from bsclifton/history-bookmark-issue
Browse files Browse the repository at this point in the history
Clearing history using modal now clears bookmark timestamps
  • Loading branch information
bbondy authored Aug 28, 2016
2 parents 67e7073 + dc5d3b7 commit 570f5e8
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 9 deletions.
8 changes: 7 additions & 1 deletion js/state/siteUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,13 @@ module.exports.filterSitesRelativeTo = function (sites, relSite) {
* @param sites The application state's Immutable sites list.
*/
module.exports.clearSitesWithoutTags = function (sites) {
return sites.filter((site) => site.get('tags') && site.get('tags').size > 0)
let clearedSites = sites.filter((site) => site.get('tags') && site.get('tags').size > 0)
clearedSites.forEach((site, index) => {
if (site.get('lastAccessedTime')) {
clearedSites = clearedSites.setIn([index, 'lastAccessedTime'], null)
}
})
return clearedSites
}

/**
Expand Down
34 changes: 26 additions & 8 deletions test/unit/state/siteUtilTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -469,15 +469,33 @@ describe('siteUtil', function () {

describe('clearSitesWithoutTags', function () {
it('does not remove sites which have a valid `tags` property', function () {
const sites = [
Immutable.fromJS({
tags: [siteTags.BOOKMARK_FOLDER]
}),
Immutable.fromJS({
tags: [siteTags.BOOKMARK]
})]
const sites = Immutable.fromJS([
{ tags: [siteTags.BOOKMARK_FOLDER] },
{ tags: [siteTags.BOOKMARK] }
])
const processedSites = siteUtil.clearSitesWithoutTags(sites)
assert.deepEqual(sites, processedSites)
assert.deepEqual(processedSites.toJS(), sites.toJS())
})
it('sets the lastAccessedTime for all entries to null', function () {
const sites = Immutable.fromJS([
{
location: 'location1',
tags: [],
lastAccessedTime: 123
},
{
location: 'location2',
tags: [siteTags.BOOKMARK],
lastAccessedTime: 123
}
])
const expectedSites = Immutable.fromJS([{
location: 'location2',
tags: [siteTags.BOOKMARK],
lastAccessedTime: null
}])
const processedSites = siteUtil.clearSitesWithoutTags(sites)
assert.deepEqual(processedSites.toJS(), expectedSites.toJS())
})
})

Expand Down

0 comments on commit 570f5e8

Please sign in to comment.