mirror of
https://github.com/makeplane/plane.git
synced 2026-05-08 00:49:36 -05:00
* fix: dashboard issue stats * chore: code refactor
This commit is contained in:
committed by
GitHub
parent
c44bf861e0
commit
99a7867a5e
@@ -13,8 +13,7 @@ export interface IIssueStoreActions {
|
||||
workspaceSlug: string,
|
||||
projectId: string,
|
||||
issueId: string,
|
||||
issueType?: "DEFAULT" | "DRAFT" | "ARCHIVED",
|
||||
shouldReplace?: boolean
|
||||
issueType?: "DEFAULT" | "DRAFT" | "ARCHIVED"
|
||||
) => Promise<TIssue>;
|
||||
updateIssue: (workspaceSlug: string, projectId: string, issueId: string, data: Partial<TIssue>) => Promise<void>;
|
||||
removeIssue: (workspaceSlug: string, projectId: string, issueId: string) => Promise<void>;
|
||||
@@ -62,13 +61,7 @@ export class IssueStore implements IIssueStore {
|
||||
});
|
||||
|
||||
// actions
|
||||
fetchIssue = async (
|
||||
workspaceSlug: string,
|
||||
projectId: string,
|
||||
issueId: string,
|
||||
issueType = "DEFAULT",
|
||||
shouldReplace = true
|
||||
) => {
|
||||
fetchIssue = async (workspaceSlug: string, projectId: string, issueId: string, issueType = "DEFAULT") => {
|
||||
const query = {
|
||||
expand: "issue_reactions,issue_attachment,issue_link,parent",
|
||||
};
|
||||
@@ -114,7 +107,7 @@ export class IssueStore implements IIssueStore {
|
||||
is_subscribed: issue?.is_subscribed,
|
||||
};
|
||||
|
||||
this.rootIssueDetailStore.rootIssueStore.issues.addIssue([issuePayload], shouldReplace);
|
||||
this.rootIssueDetailStore.rootIssueStore.issues.addIssue([issuePayload]);
|
||||
|
||||
// store handlers from issue detail
|
||||
// parent
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import update from "lodash/update";
|
||||
import isEmpty from "lodash/isEmpty";
|
||||
import set from "lodash/set";
|
||||
import { action, makeObservable, observable, runInAction } from "mobx";
|
||||
@@ -14,7 +15,7 @@ export type IIssueStore = {
|
||||
issuesMap: Record<string, TIssue>; // Record defines issue_id as key and TIssue as value
|
||||
// actions
|
||||
getIssues(workspaceSlug: string, projectId: string, issueIds: string[]): Promise<TIssue[]>;
|
||||
addIssue(issues: TIssue[], shouldReplace?: boolean): void;
|
||||
addIssue(issues: TIssue[]): void;
|
||||
updateIssue(issueId: string, issue: Partial<TIssue>): void;
|
||||
removeIssue(issueId: string): void;
|
||||
// helper methods
|
||||
@@ -47,11 +48,12 @@ export class IssueStore implements IIssueStore {
|
||||
* @param {TIssue[]} issues
|
||||
* @returns {void}
|
||||
*/
|
||||
addIssue = (issues: TIssue[], shouldReplace = false) => {
|
||||
addIssue = (issues: TIssue[]) => {
|
||||
if (issues && issues.length <= 0) return;
|
||||
runInAction(() => {
|
||||
issues.forEach((issue) => {
|
||||
if (!this.issuesMap[issue.id] || shouldReplace) set(this.issuesMap, issue.id, issue);
|
||||
if (!this.issuesMap[issue.id]) set(this.issuesMap, issue.id, issue);
|
||||
else update(this.issuesMap, issue.id, (prevIssue) => ({ ...prevIssue, ...issue }));
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user