From 71d780f765fc539ccb450f9b03789e5b7f878795 Mon Sep 17 00:00:00 2001 From: Rohit Date: Mon, 27 Jan 2025 12:12:40 +0530 Subject: [PATCH] feat: avoid rerunning the robot --- src/components/run/RunSettings.tsx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/components/run/RunSettings.tsx b/src/components/run/RunSettings.tsx index caa20e9b..33427d16 100644 --- a/src/components/run/RunSettings.tsx +++ b/src/components/run/RunSettings.tsx @@ -1,4 +1,4 @@ -import React, { useState, useEffect } from "react"; +import React, { useState, useEffect, useRef } from "react"; import { GenericModal } from "../ui/GenericModal"; import { MenuItem, TextField, Typography, Switch, FormControlLabel } from "@mui/material"; import { Dropdown } from "../ui/DropdownMui"; @@ -28,13 +28,19 @@ export const RunSettingsModal = ({ isOpen, handleStart, handleClose, isTask, par }); const [showInterpreterSettings, setShowInterpreterSettings] = useState(false); + const hasRun = useRef(false); useEffect(() => { - if (!showInterpreterSettings) { + if (!isOpen) { + hasRun.current = false; + return; + } + + if (!showInterpreterSettings && !hasRun.current) { + hasRun.current = true; handleStart(settings); } - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [showInterpreterSettings]); + }, [isOpen, showInterpreterSettings, settings, handleStart]); if (!showInterpreterSettings) { return null;