From 9d9643c40966cca4155d86fac70a089c18f8c62a Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Thu, 10 Oct 2024 02:31:54 +0530 Subject: [PATCH] feat: pass id everywhereeeeeeee --- src/pages/MainPage.tsx | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/pages/MainPage.tsx b/src/pages/MainPage.tsx index e5d04b54..f2f3e664 100644 --- a/src/pages/MainPage.tsx +++ b/src/pages/MainPage.tsx @@ -15,7 +15,7 @@ import { ScheduleSettings } from "../components/molecules/ScheduleSettings"; import { IntegrationSettings } from "../components/molecules/IntegrationSettings"; interface MainPageProps { - handleEditRecording: (fileName: string) => void; + handleEditRecording: (id: string, fileName: string) => void; } export interface CreateRunResponse { @@ -32,6 +32,7 @@ export const MainPage = ({ handleEditRecording }: MainPageProps) => { const [content, setContent] = React.useState('recordings'); const [sockets, setSockets] = React.useState([]); + const [runningRecordingId, setRunningRecordingId] = React.useState(''); const [runningRecordingName, setRunningRecordingName] = React.useState(''); const [currentInterpretationLog, setCurrentInterpretationLog] = React.useState(''); const [ids, setIds] = React.useState({ @@ -45,7 +46,7 @@ export const MainPage = ({ handleEditRecording }: MainPageProps) => { const abortRunHandler = (runId: string) => { aborted = true; - notifyAboutAbort(runningRecordingName, runId).then(async (response) => { + notifyAboutAbort(runId).then(async (response) => { if (response) { notify('success', `Interpretation of ${runningRecordingName} aborted successfully`); await stopRecording(ids.browserId); @@ -55,12 +56,13 @@ export const MainPage = ({ handleEditRecording }: MainPageProps) => { }) } - const setFileName = (fileName: string) => { - setRunningRecordingName(fileName); + const setRecordingInfo = (id: string, name: string) => { + setRunningRecordingId(id); + setRunningRecordingName(name); } const readyForRunHandler = useCallback((browserId: string, runId: string) => { - interpretStoredRecording(runningRecordingName, runId).then(async (interpretation: boolean) => { + interpretStoredRecording(runId).then(async (interpretation: boolean) => { if (!aborted) { if (interpretation) { notify('success', `Interpretation of ${runningRecordingName} succeeded`); @@ -82,7 +84,7 @@ export const MainPage = ({ handleEditRecording }: MainPageProps) => { }, [currentInterpretationLog]) const handleRunRecording = useCallback((settings: RunSettings) => { - createRunForStoredRecording(runningRecordingName, settings).then(({ browserId, runId }: CreateRunResponse) => { + createRunForStoredRecording(runningRecordingId, settings).then(({ browserId, runId }: CreateRunResponse) => { setIds({ browserId, runId }); const socket = io(`http://localhost:8080/${browserId}`, { @@ -98,7 +100,7 @@ export const MainPage = ({ handleEditRecording }: MainPageProps) => { } else { notify('error', `Failed to run recording: ${runningRecordingName}`); } - }); + }) return (socket: Socket, browserId: string, runId: string) => { socket.off('ready-for-run', () => readyForRunHandler(browserId, runId)); socket.off('debugMessage', debugMessageHandler); @@ -133,7 +135,7 @@ export const MainPage = ({ handleEditRecording }: MainPageProps) => { return ;