Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

front: reset stdcm state when hitting "new query" button #10223

Merged
merged 1 commit into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions front/src/applications/stdcm/hooks/useStdcm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ const useStdcm = ({

const { speedLimitByTag } = useStoreDataForSpeedLimitByTagSelector({ isStdcm: true });

const resetStdcmState = () => {
setStdcmTrainResult(undefined);
setStdcmTrainConflicts(undefined);
setStdcmResponse(undefined);
setPathProperties(undefined);
setCurrentStdcmRequestStatus(STDCM_REQUEST_STATUS.idle);
};

const triggerShowFailureNotification = (error: Error) => {
if (showFailureNotification) {
dispatch(setFailure(error));
Expand Down Expand Up @@ -163,6 +171,7 @@ const useStdcm = ({
stdcmResults,
launchStdcmRequest,
cancelStdcmRequest,
resetStdcmState,
pathProperties,
setPathProperties,
isPending,
Expand Down
2 changes: 2 additions & 0 deletions front/src/applications/stdcm/views/StdcmView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const StdcmView = () => {
const {
launchStdcmRequest,
cancelStdcmRequest,
resetStdcmState,
isPending,
isRejected,
isCanceled,
Expand Down Expand Up @@ -63,6 +64,7 @@ const StdcmView = () => {

const handleStartNewQuery = () => {
setSimulationsList([]);
resetStdcmState();
setSelectedSimulationIndex(-1);
setRetainedSimulationIndex(-1);
dispatch(resetStdcmConfig());
Expand Down
Loading