This repository has been archived by the owner on Dec 11, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 974
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
161 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
const assert = require('assert') | ||
const Immutable = require('immutable') | ||
const { makeImmutable, isMap, isList } = require('./immutableUtil') | ||
const siteTags = require('../../../js/constants/siteTags') | ||
const siteSettings = require('../../../js/state/siteSettings') | ||
const appConfig = require('../../../js//constants/appConfig') | ||
|
||
const validateState = function (state) { | ||
state = makeImmutable(state) | ||
assert.ok(isMap(state), 'state must be an Immutable.Map') | ||
assert.ok(isList(state.get('sites')), 'state must contain an Immutable.List of sites') | ||
return state | ||
} | ||
|
||
const siteState = { | ||
getSites: (state) => { | ||
state = validateState(state) | ||
return state.get('sites') | ||
}, | ||
|
||
getBookmarkFolders: (state) => { | ||
const sites = this.getSites(state) | ||
return sites.filter((site) => site.get('tags') | ||
.includes(siteTags.BOOKMARK_FOLDER)) || new Immutable.Map() | ||
}, | ||
|
||
getBookmarks: (state) => { | ||
const sites = this.getSites(state) | ||
return sites.filter((site) => site.get('tags') | ||
.includes(siteTags.BOOKMARK)) || new Immutable.Map() | ||
}, | ||
|
||
getAllSiteSettings: (state, frame) => { | ||
if (frame && frame.get('isPrivate')) { | ||
return state.get('siteSettings').mergeDeep(state.get('temporarySiteSettings')) | ||
} | ||
return state.get('siteSettings') | ||
}, | ||
|
||
enabledNoScript (state, settings) { | ||
return siteSettings.activeSettings(settings, state, appConfig).noScript === true | ||
} | ||
} | ||
|
||
module.exports = siteState |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.