From 92c98e9199faf10f63eb8e725d6c7b25640ef5d9 Mon Sep 17 00:00:00 2001 From: Lachlan Kermode Date: Tue, 11 Dec 2018 17:05:21 +0000 Subject: [PATCH] fix default category style --- src/actions/index.js | 30 ++++++++++++++++++++++++++++-- src/components/Dashboard.jsx | 2 +- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/actions/index.js b/src/actions/index.js index 311f4d3..590f56d 100644 --- a/src/actions/index.js +++ b/src/actions/index.js @@ -16,6 +16,16 @@ const NARRATIVE_URL = urlFromEnv('NARRATIVE_EXT'); const SITES_URL = urlFromEnv('SITES_EXT'); const eventUrlMap = (event) => `${process.env.SERVER_ROOT}${process.env.EVENT_DESC_ROOT}/${(event.id) ? event.id : event}`; + +const DEBUG_GER = 'DEBUG_GER' +function _debugger(value) { + console.log(value) + return { + type: DEBUG_GER, + value + } +} + /* * Create an error notification object * Types: ['error', 'warning', 'good', 'neural'] @@ -64,7 +74,7 @@ export function fetchDomain () { .catch(handleError('sites')) } - let tagsPromise + let tagsPromise = Promise.resolve([]) if (process.env.features.USE_TAGS) { tagsPromise = fetch(TAG_URL) .then(response => response.json()) @@ -126,7 +136,23 @@ export function fetchSelected(selected) { dispatch(fetchSourceError('No source extension specified.')) } else { dispatch(toggleFetchingSources()) - // TODO: fetching logic + + fetch(SOURCES_URL) + .then(response => { + if (!response.ok) { + throw new Error('No sources are available at the URL specified in the config specified.') + } else { + return response.json() + } + }) + .then(sources => { + dispatch(_debugger(sources)) + }) + .catch(err => { + dispatch(fetchSourceError(err.message)) + dispatch(toggleFetchingSources()) + }) + } } diff --git a/src/components/Dashboard.jsx b/src/components/Dashboard.jsx index 401d2a3..744b990 100644 --- a/src/components/Dashboard.jsx +++ b/src/components/Dashboard.jsx @@ -64,7 +64,7 @@ class Dashboard extends React.Component { } getCategoryColor(category='other') { - return this.props.ui.style.categories[category] || this.props.style.categories['other'] + return this.props.ui.style.categories[category] || this.props.ui.style.categories['other'] } getNarrativeLinks(event) {