Fix: disable file paste when chat are locked

This commit is contained in:
igorrCarvalho 2024-06-07 18:28:58 -03:00
commit bf61c339e1
2 changed files with 6 additions and 3 deletions

View file

@ -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;
};

View file

@ -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 = () => {