diff --git a/frontend/src/components/Contexts/MissionControlContext.tsx b/frontend/src/components/Contexts/MissionControlContext.tsx index 49b76e493..1013f4a8a 100644 --- a/frontend/src/components/Contexts/MissionControlContext.tsx +++ b/frontend/src/components/Contexts/MissionControlContext.tsx @@ -3,7 +3,7 @@ import { BackendAPICaller } from 'api/ApiCaller' import { MissionStatusRequest } from 'components/Pages/FrontPage/MissionOverview/StopDialogs' interface IMissionControlState { - isWaitingForResponse: boolean + isRobotMissionWaitingForResponseDict: { [robotId: string]: boolean } } interface Props { @@ -16,37 +16,39 @@ export interface IMissionControlContext { } const defaultMissionControlInterface = { - missionControlState: { isWaitingForResponse: false }, + missionControlState: { isRobotMissionWaitingForResponseDict: {} }, updateRobotMissionState: (newState: MissionStatusRequest, robotId: string) => {}, } export const MissionControlContext = createContext(defaultMissionControlInterface) const defaultManagementState: IMissionControlState = { - isWaitingForResponse: false, + isRobotMissionWaitingForResponseDict: {}, } export const MissionControlProvider: FC = ({ children }) => { const [missionControlState, setMissionControlState] = useState(defaultManagementState) - const setIsWaitingForResponse = (isWaiting: boolean) => { - setMissionControlState({ isWaitingForResponse: isWaiting }) + const setIsWaitingForResponse = (robotId: string, isWaiting: boolean) => { + const updatedDict = { ...missionControlState.isRobotMissionWaitingForResponseDict } + updatedDict[robotId] = isWaiting + setMissionControlState({ isRobotMissionWaitingForResponseDict: updatedDict }) } const updateRobotMissionState = (newState: MissionStatusRequest, robotId: string) => { switch (newState) { case MissionStatusRequest.Pause: { - setIsWaitingForResponse(true) - BackendAPICaller.pauseMission(robotId).then((_) => setIsWaitingForResponse(false)) + setIsWaitingForResponse(robotId, true) + BackendAPICaller.pauseMission(robotId).then((_) => setIsWaitingForResponse(robotId, false)) break } case MissionStatusRequest.Resume: { - setIsWaitingForResponse(true) - BackendAPICaller.resumeMission(robotId).then((_) => setIsWaitingForResponse(false)) + setIsWaitingForResponse(robotId, true) + BackendAPICaller.resumeMission(robotId).then((_) => setIsWaitingForResponse(robotId, false)) break } case MissionStatusRequest.Stop: { - setIsWaitingForResponse(true) - BackendAPICaller.stopMission(robotId).then((_) => setIsWaitingForResponse(false)) + setIsWaitingForResponse(robotId, true) + BackendAPICaller.stopMission(robotId).then((_) => setIsWaitingForResponse(robotId, false)) break } } diff --git a/frontend/src/components/Displays/MissionButtons/MissionControlButtons.tsx b/frontend/src/components/Displays/MissionButtons/MissionControlButtons.tsx index aa6fdc851..5ea7f1b6b 100644 --- a/frontend/src/components/Displays/MissionButtons/MissionControlButtons.tsx +++ b/frontend/src/components/Displays/MissionButtons/MissionControlButtons.tsx @@ -44,7 +44,7 @@ export const MissionControlButtons = ({ return ( <> - {missionControlState.isWaitingForResponse ? ( + {missionControlState.isRobotMissionWaitingForResponseDict[robotId] ? ( ) : ( <>