From bf61c339e1cc5683d4d88642a61b399ce2cabfbd Mon Sep 17 00:00:00 2001 From: igorrCarvalho Date: Fri, 7 Jun 2024 18:28:58 -0300 Subject: [PATCH] Fix: disable file paste when chat are locked --- .../components/chatView/chatInput/hooks/use-upload.tsx | 7 +++++-- .../modals/IOModal/components/chatView/chatInput/index.tsx | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/frontend/src/modals/IOModal/components/chatView/chatInput/hooks/use-upload.tsx b/src/frontend/src/modals/IOModal/components/chatView/chatInput/hooks/use-upload.tsx index 487bd7db8..88e9b3509 100644 --- a/src/frontend/src/modals/IOModal/components/chatView/chatInput/hooks/use-upload.tsx +++ b/src/frontend/src/modals/IOModal/components/chatView/chatInput/hooks/use-upload.tsx @@ -2,9 +2,12 @@ import { useEffect } from "react"; import ShortUniqueId from "short-unique-id"; import useFileUpload from "./use-file-upload"; -const useUpload = (uploadFile, currentFlowId, setFiles) => { +const useUpload = (uploadFile, currentFlowId, setFiles, lockChat) => { useEffect(() => { const handlePaste = (event: ClipboardEvent): void => { + if (lockChat) { + return; + } const items = event.clipboardData?.items; if (items) { for (let i = 0; i < items.length; i++) { @@ -27,7 +30,7 @@ const useUpload = (uploadFile, currentFlowId, setFiles) => { return () => { document.removeEventListener("paste", handlePaste); }; - }, [uploadFile, currentFlowId]); + }, [uploadFile, currentFlowId, lockChat]); return null; }; diff --git a/src/frontend/src/modals/IOModal/components/chatView/chatInput/index.tsx b/src/frontend/src/modals/IOModal/components/chatView/chatInput/index.tsx index 12209c925..22d8d4ea3 100644 --- a/src/frontend/src/modals/IOModal/components/chatView/chatInput/index.tsx +++ b/src/frontend/src/modals/IOModal/components/chatView/chatInput/index.tsx @@ -37,7 +37,7 @@ export default function ChatInput({ useFocusOnUnlock(lockChat, inputRef); useAutoResizeTextArea(chatValue, inputRef); - useUpload(uploadFile, currentFlowId, setFiles); + useUpload(uploadFile, currentFlowId, setFiles, lockChat || saveLoading); const { handleFileChange } = useHandleFileChange(setFiles, currentFlowId); const send = () => {