mirror of
https://github.com/bellingcat/ukraine-timemap.git
synced 2026-06-12 13:28:36 +03:00
simplified component logic
This commit is contained in:
@@ -177,6 +177,28 @@ class Dashboard extends React.Component {
|
||||
}
|
||||
|
||||
selectNarrativeStep (idx) {
|
||||
// Try to find idx if event passed rather than number
|
||||
if (typeof idx != 'number') {
|
||||
console.log('run')
|
||||
console.log(idx)
|
||||
let e = idx[0] || idx
|
||||
|
||||
if (this.props.app.narrative) {
|
||||
const { steps } = this.props.app.narrative
|
||||
// choose the first event at a given location
|
||||
const locationEventId = e.id
|
||||
const narrativeIdxObj = steps.find(s => s.id === locationEventId)
|
||||
let narrativeIdx = steps.indexOf(narrativeIdxObj)
|
||||
|
||||
if (narrativeIdx > -1) {
|
||||
idx = narrativeIdx
|
||||
console.log(idx)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
console.log(idx)
|
||||
|
||||
const { narrative } = this.props.app
|
||||
if (narrative === null) return
|
||||
|
||||
@@ -267,7 +289,7 @@ class Dashboard extends React.Component {
|
||||
<Timeline
|
||||
onKeyDown={this.onKeyDown}
|
||||
methods={{
|
||||
onSelect: ev => this.handleSelect(ev, 0),
|
||||
onSelect: app.narrative ? this.selectNarrativeStep : ev => this.handleSelect(ev, 0),
|
||||
onUpdateTimerange: actions.updateTimeRange,
|
||||
getCategoryColor: this.getCategoryColor
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user