From b1eb5c4ab22442bd51bf75750960a81d32a701ee Mon Sep 17 00:00:00 2001 From: JSC Date: Sun, 24 Aug 2025 13:24:34 +0200 Subject: [PATCH] feat: add extraction status update listener with toast notifications --- src/contexts/SocketContext.tsx | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) 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])