Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions web/core/components/issues/attachment/attachment-item-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,33 @@ type TAttachmentOperationsRemoveModal = Exclude<TAttachmentOperations, "create">

type TIssueAttachmentItemList = {
workspaceSlug: string;
projectId: string;
issueId: string;
handleAttachmentOperations: TAttachmentOperationsRemoveModal;
disabled?: boolean;
};

export const IssueAttachmentItemList: FC<TIssueAttachmentItemList> = observer((props) => {
const { workspaceSlug, issueId, handleAttachmentOperations, disabled } = props;
const { workspaceSlug, projectId, issueId, handleAttachmentOperations, disabled } = props;
// states
const [isLoading, setIsLoading] = useState(false);
// store hooks
const {
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;
Expand All @@ -55,7 +62,10 @@ export const IssueAttachmentItemList: FC<TIssueAttachmentItemList> = observer((p
message: "File could not be attached. Try uploading again.",
});
})
.finally(() => setIsLoading(false));
.finally(() => {
handleFetchPropertyActivities();
setIsLoading(false);
});
return;
}

Expand All @@ -69,7 +79,7 @@ export const IssueAttachmentItemList: FC<TIssueAttachmentItemList> = observer((p
});
return;
},
[handleAttachmentOperations, maxFileSize, workspaceSlug]
[handleAttachmentOperations, maxFileSize, workspaceSlug, handleFetchPropertyActivities]
);

const { getRootProps, getInputProps, isDragActive } = useDropzone({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export const IssueAttachmentsCollapsibleContent: FC<Props> = (props) => {
return (
<IssueAttachmentItemList
workspaceSlug={workspaceSlug}
projectId={projectId}
issueId={issueId}
disabled={disabled}
handleAttachmentOperations={handleAttachmentOperations}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,16 @@ export const IssueAttachmentActionButton: FC<Props> = 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;
Expand All @@ -51,6 +55,7 @@ export const IssueAttachmentActionButton: FC<Props> = observer((props) => {
});
})
.finally(() => {
handleFetchPropertyActivities();
setLastWidgetAction("attachments");
setIsLoading(false);
});
Expand All @@ -67,7 +72,7 @@ export const IssueAttachmentActionButton: FC<Props> = observer((props) => {
});
return;
},
[handleAttachmentOperations, maxFileSize, workspaceSlug]
[maxFileSize, workspaceSlug, handleAttachmentOperations, handleFetchPropertyActivities, setLastWidgetAction]
);

const { getRootProps, getInputProps } = useDropzone({
Expand Down