mirror of
https://github.com/bellingcat/ukraine-timemap.git
synced 2026-06-11 21:08:36 +03:00
Setting initial categories upon load; need to modify for timeline and related events
This commit is contained in:
@@ -107,6 +107,7 @@ export function fetchDomain () {
|
||||
throw new Error('Some URLs returned negative. If you are in development, check the server is running')
|
||||
}
|
||||
dispatch(toggleFetchingDomain())
|
||||
dispatch(setInitialCategories(result.associations))
|
||||
return result
|
||||
})
|
||||
.catch(err => {
|
||||
@@ -212,6 +213,14 @@ export function setNotLoading () {
|
||||
}
|
||||
}
|
||||
|
||||
export const SET_INITIAL_CATEGORIES = 'SET_INITIAL_CATEGORIES'
|
||||
export function setInitialCategories (values) {
|
||||
return {
|
||||
type: SET_INITIAL_CATEGORIES,
|
||||
values
|
||||
}
|
||||
}
|
||||
|
||||
export const UPDATE_TIMERANGE = 'UPDATE_TIMERANGE'
|
||||
export function updateTimeRange (timerange) {
|
||||
return {
|
||||
|
||||
@@ -305,7 +305,7 @@ class Timeline extends React.Component {
|
||||
*/
|
||||
styleDatetime (timestamp, category) {
|
||||
return [null, null]
|
||||
}
|
||||
}
|
||||
|
||||
render () {
|
||||
const { isNarrative, app } = this.props
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import initial from '../store/initial.js'
|
||||
import { ASSOCIATION_MODES } from '../common/constants'
|
||||
import { toggleFlagAC } from '../common/utilities'
|
||||
|
||||
import {
|
||||
@@ -22,6 +23,7 @@ import {
|
||||
FETCH_SOURCE_ERROR,
|
||||
SET_LOADING,
|
||||
SET_NOT_LOADING,
|
||||
SET_INITIAL_CATEGORIES,
|
||||
UPDATE_SEARCH_QUERY
|
||||
} from '../actions'
|
||||
|
||||
@@ -219,6 +221,21 @@ function setNotLoading (appState) {
|
||||
}
|
||||
}
|
||||
|
||||
function setInitialCategories (appState, action) {
|
||||
const categories = action.values.reduce((acc, val) => {
|
||||
if (val.mode === ASSOCIATION_MODES.CATEGORY) acc.push(val.id)
|
||||
return acc
|
||||
}, [])
|
||||
|
||||
return {
|
||||
...appState,
|
||||
associations: {
|
||||
...appState.associations,
|
||||
categories: categories
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function updateSearchQuery (appState, action) {
|
||||
return {
|
||||
...appState,
|
||||
@@ -270,6 +287,8 @@ function app (appState = initial.app, action) {
|
||||
return setLoading(appState)
|
||||
case SET_NOT_LOADING:
|
||||
return setNotLoading(appState)
|
||||
case SET_INITIAL_CATEGORIES:
|
||||
return setInitialCategories(appState, action)
|
||||
case UPDATE_SEARCH_QUERY:
|
||||
return updateSearchQuery(appState, action)
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user