feat: add extraction status update listener with toast notifications
This commit is contained in:
@@ -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])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user