Fix: disable file paste when chat are locked
This commit is contained in:
parent
0d3780826d
commit
bf61c339e1
2 changed files with 6 additions and 3 deletions
|
|
@ -2,9 +2,12 @@ import { useEffect } from "react";
|
||||||
import ShortUniqueId from "short-unique-id";
|
import ShortUniqueId from "short-unique-id";
|
||||||
import useFileUpload from "./use-file-upload";
|
import useFileUpload from "./use-file-upload";
|
||||||
|
|
||||||
const useUpload = (uploadFile, currentFlowId, setFiles) => {
|
const useUpload = (uploadFile, currentFlowId, setFiles, lockChat) => {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const handlePaste = (event: ClipboardEvent): void => {
|
const handlePaste = (event: ClipboardEvent): void => {
|
||||||
|
if (lockChat) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const items = event.clipboardData?.items;
|
const items = event.clipboardData?.items;
|
||||||
if (items) {
|
if (items) {
|
||||||
for (let i = 0; i < items.length; i++) {
|
for (let i = 0; i < items.length; i++) {
|
||||||
|
|
@ -27,7 +30,7 @@ const useUpload = (uploadFile, currentFlowId, setFiles) => {
|
||||||
return () => {
|
return () => {
|
||||||
document.removeEventListener("paste", handlePaste);
|
document.removeEventListener("paste", handlePaste);
|
||||||
};
|
};
|
||||||
}, [uploadFile, currentFlowId]);
|
}, [uploadFile, currentFlowId, lockChat]);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ export default function ChatInput({
|
||||||
|
|
||||||
useFocusOnUnlock(lockChat, inputRef);
|
useFocusOnUnlock(lockChat, inputRef);
|
||||||
useAutoResizeTextArea(chatValue, inputRef);
|
useAutoResizeTextArea(chatValue, inputRef);
|
||||||
useUpload(uploadFile, currentFlowId, setFiles);
|
useUpload(uploadFile, currentFlowId, setFiles, lockChat || saveLoading);
|
||||||
const { handleFileChange } = useHandleFileChange(setFiles, currentFlowId);
|
const { handleFileChange } = useHandleFileChange(setFiles, currentFlowId);
|
||||||
|
|
||||||
const send = () => {
|
const send = () => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue