From bf220666dd6d9d66643cc00a474d3d8e931277bf Mon Sep 17 00:00:00 2001 From: Prateek Shourya Date: Thu, 24 Oct 2024 14:36:30 +0530 Subject: [PATCH] [WEB-2326] fix: issue activity mutation on attachments upload. (#5886) --- .../issues/attachment/attachment-item-list.tsx | 16 +++++++++++++--- .../issue-detail-widgets/attachments/content.tsx | 1 + .../attachments/quick-action-button.tsx | 9 +++++++-- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/web/core/components/issues/attachment/attachment-item-list.tsx b/web/core/components/issues/attachment/attachment-item-list.tsx index f1af2884cd..b24cff30bb 100644 --- a/web/core/components/issues/attachment/attachment-item-list.tsx +++ b/web/core/components/issues/attachment/attachment-item-list.tsx @@ -17,13 +17,14 @@ type TAttachmentOperationsRemoveModal = Exclude type TIssueAttachmentItemList = { workspaceSlug: string; + projectId: string; issueId: string; handleAttachmentOperations: TAttachmentOperationsRemoveModal; disabled?: boolean; }; export const IssueAttachmentItemList: FC = observer((props) => { - const { workspaceSlug, issueId, handleAttachmentOperations, disabled } = props; + const { workspaceSlug, projectId, issueId, handleAttachmentOperations, disabled } = props; // states const [isLoading, setIsLoading] = useState(false); // store hooks @@ -31,12 +32,18 @@ export const IssueAttachmentItemList: FC = observer((p attachment: { getAttachmentsByIssueId }, attachmentDeleteModalId, toggleDeleteAttachmentModal, + fetchActivities, } = useIssueDetail(); // file size const { maxFileSize } = useFileSize(); // derived values const issueAttachments = getAttachmentsByIssueId(issueId); + // handlers + const handleFetchPropertyActivities = useCallback(() => { + fetchActivities(workspaceSlug, projectId, issueId); + }, [fetchActivities, workspaceSlug, projectId, issueId]); + const onDrop = useCallback( (acceptedFiles: File[], rejectedFiles: FileRejection[]) => { const totalAttachedFiles = acceptedFiles.length + rejectedFiles.length; @@ -55,7 +62,10 @@ export const IssueAttachmentItemList: FC = observer((p message: "File could not be attached. Try uploading again.", }); }) - .finally(() => setIsLoading(false)); + .finally(() => { + handleFetchPropertyActivities(); + setIsLoading(false); + }); return; } @@ -69,7 +79,7 @@ export const IssueAttachmentItemList: FC = observer((p }); return; }, - [handleAttachmentOperations, maxFileSize, workspaceSlug] + [handleAttachmentOperations, maxFileSize, workspaceSlug, handleFetchPropertyActivities] ); const { getRootProps, getInputProps, isDragActive } = useDropzone({ diff --git a/web/core/components/issues/issue-detail-widgets/attachments/content.tsx b/web/core/components/issues/issue-detail-widgets/attachments/content.tsx index f792af2844..5df62819dc 100644 --- a/web/core/components/issues/issue-detail-widgets/attachments/content.tsx +++ b/web/core/components/issues/issue-detail-widgets/attachments/content.tsx @@ -19,6 +19,7 @@ export const IssueAttachmentsCollapsibleContent: FC = (props) => { return ( = observer((props) => { // state const [isLoading, setIsLoading] = useState(false); // store hooks - const { setLastWidgetAction } = useIssueDetail(); + const { setLastWidgetAction, fetchActivities } = useIssueDetail(); // file size const { maxFileSize } = useFileSize(); // operations const handleAttachmentOperations = useAttachmentOperations(workspaceSlug, projectId, issueId); // handlers + const handleFetchPropertyActivities = useCallback(() => { + fetchActivities(workspaceSlug, projectId, issueId); + }, [fetchActivities, workspaceSlug, projectId, issueId]); + const onDrop = useCallback( (acceptedFiles: File[], rejectedFiles: FileRejection[]) => { const totalAttachedFiles = acceptedFiles.length + rejectedFiles.length; @@ -51,6 +55,7 @@ export const IssueAttachmentActionButton: FC = observer((props) => { }); }) .finally(() => { + handleFetchPropertyActivities(); setLastWidgetAction("attachments"); setIsLoading(false); }); @@ -67,7 +72,7 @@ export const IssueAttachmentActionButton: FC = observer((props) => { }); return; }, - [handleAttachmentOperations, maxFileSize, workspaceSlug] + [maxFileSize, workspaceSlug, handleAttachmentOperations, handleFetchPropertyActivities, setLastWidgetAction] ); const { getRootProps, getInputProps } = useDropzone({