summaryrefslogtreecommitdiff
path: root/frontend/src/containers/app/timeline/TimelineControlsContainer.js
blob: 92e03e6a93fae021f7b756d66a401f3123487e95 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { connect } from 'react-redux'
import { goToTick } from '../../../actions/simulation/tick'
import TimelineControlsComponent from '../../../components/app/timeline/TimelineControlsComponent'

const mapStateToProps = state => {
    let sectionTicks = []
    if (state.currentExperimentId !== -1) {
        const sectionIds =
            state.objects.path[
                state.objects.experiment[state.currentExperimentId].pathId
                ].sectionIds
        if (sectionIds) {
            sectionTicks = sectionIds
                .filter(sectionId => state.objects.section[sectionId].startTick !== 0)
                .map(sectionId => state.objects.section[sectionId].startTick)
        }
    }

    return {
        currentTick: state.currentTick,
        lastSimulatedTick: state.lastSimulatedTick,
        sectionTicks,
    }
}

const mapDispatchToProps = dispatch => {
    return {
        goToTick: tick => dispatch(goToTick(tick)),
    }
}

const TimelineControlsContainer = connect(mapStateToProps, mapDispatchToProps)(
    TimelineControlsComponent,
)

export default TimelineControlsContainer