diff --git a/src/components/Dashboard/context/ApiServerContext.jsx b/src/components/Dashboard/context/ApiServerContext.jsx index cd1462e..cc5537b 100644 --- a/src/components/Dashboard/context/ApiServerContext.jsx +++ b/src/components/Dashboard/context/ApiServerContext.jsx @@ -308,9 +308,14 @@ const ApiServerProvider = ({ children }) => { .get(callbacksRefKey) .filter((cb) => cb !== callback) if (callbacks.length === 0) { + logger.debug( + 'No callbacks found for object:', + callbacksRefKey, + 'unsubscribing from object update...' + ) subscribedCallbacksRef.current.delete(callbacksRefKey) socketRef.current.emit('unsubscribeObjectUpdate', { - id: id, + _id: id, objectType: objectType }) } else { @@ -529,7 +534,7 @@ const ApiServerProvider = ({ children }) => { `Added lock callback for object ${id}, total lock callbacks: ${subscribedLockCallbacksRef.current.get(id).length}` ) - socketRef.current.emit('subscribe_lock', { id: id, type: type }) + socketRef.current.emit('subscribe_lock', { _id: id, objectType: type }) logger.debug('Registered lock event listener for object:', id) // Return cleanup function @@ -853,6 +858,21 @@ const ApiServerProvider = ({ children }) => { } } + const fetchTemplatePDF = async (id, content, testObject, callback) => { + logger.debug('Fetching preview...') + if (socketRef.current && socketRef.current.connected) { + return socketRef.current.emit( + 'renderTemplatePDF', + { + _id: id, + content: content, + object: testObject + }, + callback + ) + } + } + const fetchHostOTP = async (id, callback) => { logger.debug('Fetching host OTP...') if (socketRef.current && socketRef.current.connected) { @@ -967,6 +987,7 @@ const ApiServerProvider = ({ children }) => { showError, fetchFileContent, fetchTemplatePreview, + fetchTemplatePDF, fetchNotes, fetchHostOTP, sendObjectAction,