summaryrefslogtreecommitdiff
path: root/src/containers/app/timeline/TimelineControlsContainer.js
blob: e91a0aca1b3a659f7e374fd219cf61c1becfa861 (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
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;