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 972
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
3 changed files
with
97 additions
and
49 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
const assert = require('assert') | ||
const { makeImmutable, isMap, isList } = require('./immutableUtil') | ||
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') | ||
}, | ||
|
||
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
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