mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
chore: update useCallback dependencies (#4341)
This commit is contained in:
parent
4c78cd7c7e
commit
45c9dfb3cf
@ -1,11 +1,11 @@
|
|||||||
import { useCallback, useState } from "react";
|
import { useCallback, useState } from "react";
|
||||||
import { observer } from "mobx-react-lite";
|
import { observer } from "mobx-react-lite";
|
||||||
import { useDropzone } from "react-dropzone";
|
import { useDropzone } from "react-dropzone";
|
||||||
// hooks
|
|
||||||
// constants
|
// constants
|
||||||
import { MAX_FILE_SIZE } from "@/constants/common";
|
import { MAX_FILE_SIZE } from "@/constants/common";
|
||||||
// helpers
|
// helpers
|
||||||
import { generateFileName } from "@/helpers/attachment.helper";
|
import { generateFileName } from "@/helpers/attachment.helper";
|
||||||
|
// hooks
|
||||||
import { useApplication } from "@/hooks/store";
|
import { useApplication } from "@/hooks/store";
|
||||||
// types
|
// types
|
||||||
import { TAttachmentOperations } from "./root";
|
import { TAttachmentOperations } from "./root";
|
||||||
@ -27,11 +27,14 @@ export const IssueAttachmentUpload: React.FC<Props> = observer((props) => {
|
|||||||
// states
|
// states
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
|
|
||||||
const onDrop = useCallback((acceptedFiles: File[]) => {
|
const onDrop = useCallback(
|
||||||
|
(acceptedFiles: File[]) => {
|
||||||
const currentFile: File = acceptedFiles[0];
|
const currentFile: File = acceptedFiles[0];
|
||||||
if (!currentFile || !workspaceSlug) return;
|
if (!currentFile || !workspaceSlug) return;
|
||||||
|
|
||||||
const uploadedFile: File = new File([currentFile], generateFileName(currentFile.name), { type: currentFile.type });
|
const uploadedFile: File = new File([currentFile], generateFileName(currentFile.name), {
|
||||||
|
type: currentFile.type,
|
||||||
|
});
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append("asset", uploadedFile);
|
formData.append("asset", uploadedFile);
|
||||||
formData.append(
|
formData.append(
|
||||||
@ -43,8 +46,9 @@ export const IssueAttachmentUpload: React.FC<Props> = observer((props) => {
|
|||||||
);
|
);
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
handleAttachmentOperations.create(formData).finally(() => setIsLoading(false));
|
handleAttachmentOperations.create(formData).finally(() => setIsLoading(false));
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
},
|
||||||
}, []);
|
[handleAttachmentOperations, workspaceSlug]
|
||||||
|
);
|
||||||
|
|
||||||
const { getRootProps, getInputProps, isDragActive, isDragReject, fileRejections } = useDropzone({
|
const { getRootProps, getInputProps, isDragActive, isDragReject, fileRejections } = useDropzone({
|
||||||
onDrop,
|
onDrop,
|
||||||
|
@ -95,7 +95,7 @@ export const IssueAttachmentRoot: FC<TIssueAttachmentRoot> = (props) => {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
[workspaceSlug, projectId, issueId, createAttachment, removeAttachment]
|
[captureIssueEvent, workspaceSlug, projectId, issueId, createAttachment, removeAttachment]
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
Loading…
Reference in New Issue
Block a user