rewrite features as part of store + add HIGHLIGHT_GROUPS

This commit is contained in:
Lachlan Kermode
2020-05-19 14:08:03 +02:00
parent 154b62f924
commit e93d7d8831
16 changed files with 151 additions and 84 deletions

View File

@@ -23,7 +23,8 @@ export function fetchDomain () {
return []
}
return dispatch => {
return (dispatch, getState) => {
const features = getState().features
dispatch(toggleFetchingDomain())
const eventPromise = fetch(EVENT_DATA_URL)
@@ -35,21 +36,21 @@ export function fetchDomain () {
.catch(() => handleError(domainMsg('categories')))
let narPromise = Promise.resolve([])
if (process.env.features.USE_NARRATIVES) {
if (features.USE_NARRATIVES) {
narPromise = fetch(NARRATIVE_URL)
.then(response => response.json())
.catch(() => handleError(domainMsg('narratives')))
}
let sitesPromise = Promise.resolve([])
if (process.env.features.USE_SITES) {
if (features.USE_SITES) {
sitesPromise = fetch(SITES_URL)
.then(response => response.json())
.catch(() => handleError(domainMsg('sites')))
}
let tagsPromise = Promise.resolve([])
if (process.env.features.USE_TAGS) {
if (features.USE_TAGS) {
if (!TAGS_URL) {
tagsPromise = Promise.resolve(handleError('USE_TAGS is true, but you have not provided a TAGS_EXT'))
} else {
@@ -60,7 +61,7 @@ export function fetchDomain () {
}
let sourcesPromise = Promise.resolve([])
if (process.env.features.USE_SOURCES) {
if (features.USE_SOURCES) {
if (!SOURCES_URL) {
sourcesPromise = Promise.resolve(handleError('USE_SOURCES is true, but you have not provided a SOURCES_EXT'))
} else {
@@ -71,7 +72,7 @@ export function fetchDomain () {
}
let shapesPromise = Promise.resolve([])
if (process.env.features.USE_SHAPES) {
if (features.USE_SHAPES) {
shapesPromise = fetch(SHAPES_URL)
.then(response => response.json())
.catch(() => handleError(domainMsg('shapes')))