feat: move workflow socket

This commit is contained in:
karishmas6
2024-10-08 18:05:57 +05:30
parent 398d0036cd
commit 8e07de54e7

View File

@@ -61,6 +61,9 @@ export const RightSidePanel: React.FC<RightSidePanelProps> = ({ onFinishCapture
}, [workflow])
useEffect(() => {
if (socket) {
socket.on("workflow", workflowHandler);
}
// fetch the workflow every time the id changes
if (id) {
fetchWorkflow(id, workflowHandler);
@@ -71,7 +74,10 @@ export const RightSidePanel: React.FC<RightSidePanelProps> = ({ onFinishCapture
fetchWorkflow(id, workflowHandler);
}
}, (1000 * 60 * 15));
return () => clearInterval(interval)
return () => {
socket?.off("workflow", workflowHandler);
clearInterval(interval);
};
}, [id]);
useEffect(() => {
@@ -84,6 +90,13 @@ export const RightSidePanel: React.FC<RightSidePanelProps> = ({ onFinishCapture
}
}, [socket, workflowHandler]);
const hasScrapeListAction = workflow.workflow.some(pair =>
pair.what.some(action => action.action === "scrapeList")
);
console.log(`Has Scrape List Action?`, hasScrapeListAction); // true if any pair contains scrapeList action
const handleTextLabelChange = (id: number, label: string, listId?: number, fieldKey?: string) => {
if (listId !== undefined && fieldKey !== undefined) {
// Prevent editing if the field is confirmed