diff --git a/src/contexts/SocketContext.tsx b/src/contexts/SocketContext.tsx index 857505f..bb3f62e 100644 --- a/src/contexts/SocketContext.tsx +++ b/src/contexts/SocketContext.tsx @@ -103,6 +103,33 @@ export function SocketProvider({ children }: SocketProviderProps) { userEvents.emit(USER_EVENTS.USER_CREDITS_CHANGED, data) }) + // Listen for extraction status updates + newSocket.on('extraction_status_update', data => { + const { extraction_id, status, title, error } = data + + switch (status) { + case 'processing': + toast.loading(`Extracting: ${title}`, { + id: `extraction-${extraction_id}`, + duration: Infinity, // Keep it open until status changes + }) + break + case 'completed': + toast.dismiss(`extraction-${extraction_id}`) + toast.success(`Extraction complete: ${title}`, { + duration: 4000, + }) + break + case 'failed': + toast.dismiss(`extraction-${extraction_id}`) + toast.error(`Extraction failed: ${title}`, { + description: error, + duration: 6000, + }) + break + } + }) + return newSocket }, [user])