@@ -31,7 +31,7 @@ import TimeButtons from 'applications/osrd/views/OSRDSimulation/TimeButtons';
31
31
import TimeLine from 'applications/osrd/components/TimeLine/TimeLine' ;
32
32
import TrainDetails from 'applications/osrd/views/OSRDSimulation/TrainDetails' ;
33
33
import TrainList from 'applications/osrd/views/OSRDSimulation/TrainList' ;
34
- import createTrain from 'applications/osrd/components/Simulation/SpaceTimeChart/createTrain' ;
34
+
35
35
import { trainscheduleURI } from 'applications/osrd/components/Simulation/consts' ;
36
36
import { get } from 'common/requests' ;
37
37
import { sec2time } from 'utils/timeManipulation' ;
@@ -40,7 +40,6 @@ import { setFailure } from 'reducers/main';
40
40
import { updateViewport , Viewport } from 'reducers/map' ;
41
41
import { useTranslation } from 'react-i18next' ;
42
42
43
- export const KEY_VALUES_FOR_CONSOLIDATED_SIMULATION = [ 'time' , 'position' ] ;
44
43
export const timetableURI = '/timetable/' ;
45
44
const MAP_MIN_HEIGHT = 450 ;
46
45
@@ -77,22 +76,30 @@ function OSRDSimulation() {
77
76
useState ( heightOfSpaceCurvesSlopesChart ) ;
78
77
79
78
const { timetableID } = useSelector ( ( state : RootState ) => state . osrdconf ) ;
80
- const {
81
- allowancesSettings,
82
- selectedProjection,
83
- departureArrivalTimes,
84
- selectedTrain,
85
- stickyBar,
86
- } = useSelector ( ( state : RootState ) => state . osrdsimulation ) ;
87
- const simulation = useSelector ( ( state : RootState ) => state . osrdsimulation . simulation . present ) ;
79
+
80
+ const allowancesSettings = useSelector (
81
+ ( state : RootState ) => state . osrdsimulation . allowancesSettings
82
+ ) ;
83
+ const selectedProjection = useSelector (
84
+ ( state : RootState ) => state . osrdsimulation . selectedProjection
85
+ ) ;
86
+ const departureArrivalTimes = useSelector (
87
+ ( state : RootState ) => state . osrdsimulation . departureArrivalTimes
88
+ ) ;
89
+ const selectedTrain = useSelector ( ( state : RootState ) => state . osrdsimulation . selectedTrain ) ;
90
+ const stickyBar = useSelector ( ( state : RootState ) => state . osrdsimulation . stickyBar ) ;
91
+ const displaySimulation = useSelector (
92
+ ( state : RootState ) => state . osrdsimulation . displaySimulation
93
+ ) ;
94
+ //const simulation = useSelector((state: RootState) => state.osrdsimulation.simulation.present);
88
95
const dispatch = useDispatch ( ) ;
89
96
90
97
/**
91
98
* Recover the time table for all the trains
92
99
*/
93
100
const getTimetable = async ( ) => {
94
101
try {
95
- if ( ! simulation . trains || ! simulation . trains [ selectedTrain ] ) {
102
+ if ( displaySimulation ) {
96
103
dispatch ( updateSelectedTrain ( 0 ) ) ;
97
104
}
98
105
const timetable = await get ( `${ timetableURI } ${ timetableID } /` ) ;
@@ -188,19 +195,6 @@ function OSRDSimulation() {
188
195
}
189
196
} , [ extViewport ] ) ;
190
197
191
- // With this hook we update and store
192
- // the consolidatedSimuation (simualtion stucture for the selected train)
193
- useEffect ( ( ) => {
194
- const consolidatedSimulation = createTrain (
195
- dispatch ,
196
- KEY_VALUES_FOR_CONSOLIDATED_SIMULATION ,
197
- simulation . trains ,
198
- t
199
- ) ;
200
- // Store it to allow time->position logic to be hosted by redux
201
- dispatch ( updateConsolidatedSimulation ( consolidatedSimulation ) ) ;
202
- } , [ simulation ] ) ;
203
-
204
198
const waitingLoader = isEmpty ? (
205
199
< h1 className = "text-center" > { t ( 'simulation:noData' ) } </ h1 >
206
200
) : (
@@ -210,7 +204,7 @@ function OSRDSimulation() {
210
204
const mapMaxHeight = getMapMaxHeight ( timeTableRef ) ;
211
205
return (
212
206
< main className = { `mastcontainer ${ fullscreen ? ' fullscreen' : '' } ` } >
213
- { ! simulation || simulation . trains . length === 0 ? (
207
+ { ! displaySimulation ? (
214
208
< div className = "pt-5 mt-5" > { waitingLoader } </ div >
215
209
) : (
216
210
< div className = "m-0 p-3" >
@@ -254,7 +248,7 @@ function OSRDSimulation() {
254
248
className = "spacetimechart-container"
255
249
style = { { height : `${ heightOfSpaceTimeChart } px` } }
256
250
>
257
- { simulation . trains . length > 0 && (
251
+ { displaySimulation && (
258
252
< Rnd
259
253
default = { {
260
254
x : 0 ,
@@ -285,7 +279,7 @@ function OSRDSimulation() {
285
279
className = "speedspacechart-container"
286
280
style = { { height : `${ heightOfSpeedSpaceChart } px` } }
287
281
>
288
- { simulation . trains . length > 0 && (
282
+ { displaySimulation && (
289
283
< Rnd
290
284
default = { {
291
285
x : 0 ,
@@ -315,7 +309,7 @@ function OSRDSimulation() {
315
309
className = "spacecurvesslopes-container"
316
310
style = { { height : `${ heightOfSpaceCurvesSlopesChart } px` } }
317
311
>
318
- { simulation . trains . length > 0 && (
312
+ { displaySimulation && (
319
313
< Rnd
320
314
default = { {
321
315
x : 0 ,
@@ -406,9 +400,7 @@ function OSRDSimulation() {
406
400
< div className = "col-lg-4" >
407
401
< TimeButtons />
408
402
</ div >
409
- < div className = "col-lg-8" >
410
- { simulation . trains . length > 0 ? < TrainDetails /> : null }
411
- </ div >
403
+ < div className = "col-lg-8" > { displaySimulation ? < TrainDetails /> : null } </ div >
412
404
</ div >
413
405
</ div >
414
406
) : (
0 commit comments