Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,19 @@ export const IssueDetailQuickActions: FC<Props> = observer((props) => {

const handleDeleteIssue = async () => {
try {
if (issue?.archived_at) {
return removeArchivedIssue(workspaceSlug, projectId, issueId).then(() => {
router.push(`/${workspaceSlug}/projects/${projectId}/issues`);
captureIssueEvent({
eventName: ISSUE_DELETED,
payload: { id: issueId, state: "SUCCESS", element: "Issue detail page" },
path: pathname,
});
const deleteIssue = issue?.archived_at ? removeArchivedIssue : removeIssue;
const redirectionPath = issue?.archived_at
? `/${workspaceSlug}/projects/${projectId}/archives/issues`
: `/${workspaceSlug}/projects/${projectId}/issues`;

return deleteIssue(workspaceSlug, projectId, issueId).then(() => {
router.push(redirectionPath);
captureIssueEvent({
eventName: ISSUE_DELETED,
payload: { id: issueId, state: "SUCCESS", element: "Issue detail page" },
path: pathname,
});
} else {
return removeIssue(workspaceSlug, projectId, issueId);
}
});
Comment on lines +86 to +93
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure proper error handling

The refactored code correctly handles errors by displaying a toast message and capturing the issue event. However, consider logging the error for debugging purposes.

 try {
   const deleteIssue = issue?.archived_at ? removeArchivedIssue : removeIssue;
   const redirectionPath = issue?.archived_at
     ? `/${workspaceSlug}/projects/${projectId}/archives/issues`
     : `/${workspaceSlug}/projects/${projectId}/issues`;

   return deleteIssue(workspaceSlug, projectId, issueId).then(() => {
     router.push(redirectionPath);
     captureIssueEvent({
       eventName: ISSUE_DELETED,
       payload: { id: issueId, state: "SUCCESS", element: "Issue detail page" },
       path: pathname,
     });
   });
 } catch (error) {
+  console.error("Error deleting issue:", error);
   setToast({
     title: "Error!",
     type: TOAST_TYPE.ERROR,
     message: "Issue delete failed",
   });
   captureIssueEvent({
     eventName: ISSUE_DELETED,
     payload: { id: issueId, state: "FAILED", element: "Issue detail page" },
     path: pathname,
   });
 }

Consider logging the error for debugging purposes.

Committable suggestion was skipped due to low confidence.

} catch (error) {
setToast({
title: "Error!",
Expand Down