diff --git a/web/components/core/modals/bulk-delete-issues-modal.tsx b/web/components/core/modals/bulk-delete-issues-modal.tsx index 6bb646821..f5eab83ef 100644 --- a/web/components/core/modals/bulk-delete-issues-modal.tsx +++ b/web/components/core/modals/bulk-delete-issues-modal.tsx @@ -17,9 +17,11 @@ import { IUser, TIssue } from "@plane/types"; // fetch keys import { PROJECT_ISSUES_LIST } from "constants/fetch-keys"; // store hooks -import { useProject } from "hooks/store"; +import { useIssues, useProject } from "hooks/store"; // components import { BulkDeleteIssuesModalItem } from "./bulk-delete-issues-modal-item"; +// constants +import { EIssuesStoreType } from "constants/issue"; type FormInput = { delete_issue_ids: string[]; @@ -40,6 +42,9 @@ export const BulkDeleteIssuesModal: React.FC = observer((props) => { const { workspaceSlug, projectId } = router.query; // hooks const { getProjectById } = useProject(); + const { + issues: { removeBulkIssues }, + } = useIssues(EIssuesStoreType.PROJECT); // states const [query, setQuery] = useState(""); // fetching project issues. @@ -82,17 +87,13 @@ export const BulkDeleteIssuesModal: React.FC = observer((props) => { if (!Array.isArray(data.delete_issue_ids)) data.delete_issue_ids = [data.delete_issue_ids]; - await issueService - .bulkDeleteIssues(workspaceSlug as string, projectId as string, { - issue_ids: data.delete_issue_ids, - }) + await removeBulkIssues(workspaceSlug as string, projectId as string, data.delete_issue_ids) .then(() => { setToastAlert({ type: "success", title: "Success!", message: "Issues deleted successfully!", }); - handleClose(); }) .catch(() => diff --git a/web/store/issue/project/issue.store.ts b/web/store/issue/project/issue.store.ts index 898278943..a375ef5a9 100644 --- a/web/store/issue/project/issue.store.ts +++ b/web/store/issue/project/issue.store.ts @@ -24,6 +24,7 @@ export interface IProjectIssues { updateIssue: (workspaceSlug: string, projectId: string, issueId: string, data: Partial) => Promise; removeIssue: (workspaceSlug: string, projectId: string, issueId: string) => Promise; quickAddIssue: (workspaceSlug: string, projectId: string, data: TIssue) => Promise; + removeBulkIssues: (workspaceSlug: string, projectId: string, issueIds: string[]) => Promise; } export class ProjectIssues extends IssueHelperStore implements IProjectIssues { @@ -53,6 +54,7 @@ export class ProjectIssues extends IssueHelperStore implements IProjectIssues { createIssue: action, updateIssue: action, removeIssue: action, + removeBulkIssues: action, quickAddIssue: action, }); // root store @@ -185,4 +187,22 @@ export class ProjectIssues extends IssueHelperStore implements IProjectIssues { throw error; } }; + + removeBulkIssues = async (workspaceSlug: string, projectId: string, issueIds: string[]) => { + try { + runInAction(() => { + issueIds.forEach((issueId) => { + pull(this.issues[projectId], issueId); + this.rootStore.issues.removeIssue(issueId); + }); + }); + + const response = await this.issueService.bulkDeleteIssues(workspaceSlug, projectId, { issue_ids: issueIds }); + + return response; + } catch (error) { + this.fetchIssues(workspaceSlug, projectId, "mutation"); + throw error; + } + }; } diff --git a/web/store/issue/workspace/filter.store.ts b/web/store/issue/workspace/filter.store.ts index df207fee9..48c1acd53 100644 --- a/web/store/issue/workspace/filter.store.ts +++ b/web/store/issue/workspace/filter.store.ts @@ -164,8 +164,6 @@ export class WorkspaceIssuesFilter extends IssueFilterHelperStore implements IWo if (!viewId) throw new Error("View id is required"); const issueFilters = this.getIssueFilters(viewId); - console.log("issueFilters", issueFilters); - if (!issueFilters || isEmpty(filters)) return; const _filters = {