diff --git a/frontend/src/components/WorkspaceChat/ChatContainer/PromptInput/index.jsx b/frontend/src/components/WorkspaceChat/ChatContainer/PromptInput/index.jsx index 6c4998a54..ffa71f72e 100644 --- a/frontend/src/components/WorkspaceChat/ChatContainer/PromptInput/index.jsx +++ b/frontend/src/components/WorkspaceChat/ChatContainer/PromptInput/index.jsx @@ -360,20 +360,15 @@ function useIsDisabled() { */ useEffect(() => { if (!window) return; - window.addEventListener(ATTACHMENTS_PROCESSING_EVENT, () => - setIsDisabled(true) - ); - window.addEventListener(ATTACHMENTS_PROCESSED_EVENT, () => - setIsDisabled(false) - ); + const onProcessing = () => setIsDisabled(true); + const onProcessed = () => setIsDisabled(false); + + window.addEventListener(ATTACHMENTS_PROCESSING_EVENT, onProcessing); + window.addEventListener(ATTACHMENTS_PROCESSED_EVENT, onProcessed); return () => { - window?.removeEventListener(ATTACHMENTS_PROCESSING_EVENT, () => - setIsDisabled(true) - ); - window?.removeEventListener(ATTACHMENTS_PROCESSED_EVENT, () => - setIsDisabled(false) - ); + window.removeEventListener(ATTACHMENTS_PROCESSING_EVENT, onProcessing); + window.removeEventListener(ATTACHMENTS_PROCESSED_EVENT, onProcessed); }; }, []);