From e3a8441d1ef3c50375516dd02e74a46299b6f26a Mon Sep 17 00:00:00 2001 From: Rohit Date: Tue, 11 Mar 2025 20:28:33 +0530 Subject: [PATCH] feat: read notif and rerender robots --- src/components/robot/RecordingsTable.tsx | 26 ++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/components/robot/RecordingsTable.tsx b/src/components/robot/RecordingsTable.tsx index 75b68717..4fd1d59a 100644 --- a/src/components/robot/RecordingsTable.tsx +++ b/src/components/robot/RecordingsTable.tsx @@ -176,6 +176,32 @@ export const RecordingsTable = ({ setRecordingId } = useGlobalInfoStore(); const navigate = useNavigate(); + useEffect(() => { + const handleMessage = (event: any) => { + if (event.data && event.data.type === 'recording-notification') { + console.log('Received message from recording tab:', event.data); + + const notificationData = event.data.notification; + if (notificationData) { + notify(notificationData.type, notificationData.message); + + if ((notificationData.type === 'success' && + notificationData.message.includes('saved')) || + (notificationData.type === 'warning' && + notificationData.message.includes('terminated'))) { + setRerenderRobots(true); + } + } + } + }; + + window.addEventListener('message', handleMessage); + + return () => { + window.removeEventListener('message', handleMessage); + }; + }, [notify, setRerenderRobots]); + const handleChangePage = useCallback((event: unknown, newPage: number) => { setPage(newPage); }, []);