Skip to content
Open
4 changes: 3 additions & 1 deletion src/components/page-header/procedures/change-type-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
changeNodesColorInBatch,
changeStationsTypeInBatch,
changeZIndexInBatch,
checkAndChangeStationIntType,
} from '../../../util/change-types';
import { findThemes } from '../../../util/color';
import { usePaletteTheme } from '../../../util/hooks';
Expand Down Expand Up @@ -66,7 +67,7 @@ export const ChangeTypeModal = (props: {
const dispatch = useRootDispatch();
const { selected } = useRootSelector(state => state.runtime);
const {
preference: { autoParallel },
preference: { autoParallel, autoChangeStationType },
} = useRootSelector(state => state.app);
const { activeSubscriptions } = useRootSelector(state => state.account);

Expand Down Expand Up @@ -290,6 +291,7 @@ export const ChangeTypeModal = (props: {
: (graph.current.edges() as LineId[]);
if ((!filter || filter.includes('station')) && isStationTypeSwitch) {
changeStationsTypeInBatch(graph.current, currentStationType, newStationType, stations);
if (autoChangeStationType) stations.forEach(s => checkAndChangeStationIntType(graph.current, s as StnId));
}
if ((!filter || filter.includes('line')) && isLineStyleTypeSwitch) {
changeLineStyleTypeInBatch(graph.current, currentLineStyleType, newLineStyleType, newTheme, lines);
Expand Down
8 changes: 7 additions & 1 deletion src/components/panels/details/station-type-section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ import { RmgLabel, RmgSelect } from '@railmapgen/rmg-components';
import React from 'react';
import { useTranslation } from 'react-i18next';
import { StationType } from '../../../constants/stations';
import { StnId } from '../../../constants/constants';
import { useRootDispatch, useRootSelector } from '../../../redux';
import { saveGraph } from '../../../redux/param/param-slice';
import { refreshNodesThunk } from '../../../redux/runtime/runtime-slice';
import { changeStationType } from '../../../util/change-types';
import { autoPopulateTransfer, changeStationType } from '../../../util/change-types';
import stations from '../../svgs/stations/stations';

export default function StationTypeSection() {
Expand All @@ -29,6 +30,9 @@ export default function StationTypeSection() {
selected,
refresh: { nodes: refreshNodes },
} = useRootSelector(state => state.runtime);
const {
preference: { autoChangeStationType },
} = useRootSelector(state => state.app);
const [selectedFirst] = selected;
const graph = React.useRef(window.graph);

Expand All @@ -51,6 +55,8 @@ export default function StationTypeSection() {
const handleChangeStationType = () => {
if (newType) {
changeStationType(graph.current, selectedFirst!, newType);
if (autoChangeStationType && selectedFirst.startsWith('stn'))
autoPopulateTransfer(graph.current, selectedFirst! as StnId);
hardRefresh();
}
};
Expand Down
Loading