Skip to content

Commit

Permalink
re add selected train id to chart synchronizer v1
Browse files Browse the repository at this point in the history
  • Loading branch information
SharglutDev committed May 31, 2024
1 parent e4e4230 commit b8baf63
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ export class ChartSynchronizer {
this.subscribers.delete(key);
}

computePositionValues() {
computePositionValues(newTrainId?: number) {
if (!this.reduxStore) {
throw new Error('Redux store reference was not set in Chart synchronizer');
}
const osrdSimulation = this.reduxStore.getState().osrdsimulation;
const trainId = osrdSimulation.selectedTrainId;
const trainId = newTrainId || osrdSimulation.selectedTrainId;
const currentTrainSimulation = osrdSimulation.consolidatedSimulation.find(
(consolidatedSimulation: SimulationTrain) => consolidatedSimulation.id === trainId
);
Expand Down
2 changes: 1 addition & 1 deletion front/src/reducers/osrdsimulation/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export function updateSelectedProjection(

export function updateSelectedTrainId(selectedTrainId: OsrdSimulationState['selectedTrainId']) {
return (dispatch: Dispatch, _: GetState, chartSynchronizer: ChartSynchronizer) => {
chartSynchronizer.computePositionValues();
chartSynchronizer.computePositionValues(selectedTrainId);
dispatch({
type: UPDATE_SELECTED_TRAIN_ID,
selectedTrainId,
Expand Down

0 comments on commit b8baf63

Please sign in to comment.