-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[WEB-2001] chore: Code refactor for noload changes. #5683
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
45936e9
33dc931
e0f0a09
d6f6333
bbecefb
3c0b5bf
d279013
7d3b799
abf341b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -19,12 +19,12 @@ const ArchivedIssueDetailsPage = observer(() => { | |||||
| // hooks | ||||||
| const { | ||||||
| fetchIssue, | ||||||
| issue: { getIssueById }, | ||||||
| issue: { getIssueById, isFetchingIssueDetails }, | ||||||
| } = useIssueDetail(); | ||||||
|
|
||||||
| const { getProjectById } = useProject(); | ||||||
|
|
||||||
| const { isLoading } = useSWR( | ||||||
| useSWR( | ||||||
| workspaceSlug && projectId && archivedIssueId | ||||||
| ? `ARCHIVED_ISSUE_DETAIL_${workspaceSlug}_${projectId}_${archivedIssueId}` | ||||||
| : null, | ||||||
|
|
@@ -40,7 +40,7 @@ const ArchivedIssueDetailsPage = observer(() => { | |||||
|
|
||||||
| if (!issue) return <></>; | ||||||
|
|
||||||
| const issueLoader = !issue || isLoading ? true : false; | ||||||
| const issueLoader = !issue || isFetchingIssueDetails ? true : false; | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Approve logic change, but simplify the expression The updated However, the expression can be simplified: -const issueLoader = !issue || isFetchingIssueDetails ? true : false;
+const issueLoader = !issue || isFetchingIssueDetails;This simplification removes the unnecessary ternary operator, making the code more concise and easier to read while maintaining the same functionality. Committable suggestion
Suggested change
ToolsBiome
|
||||||
|
|
||||||
| return ( | ||||||
| <> | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,6 +1,6 @@ | ||||||||||||||||||||||||||||||||||||||
| import { useState, useEffect, useCallback } from "react"; | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| const getValueFromLocalStorage = (key: string, defaultValue: any) => { | ||||||||||||||||||||||||||||||||||||||
| export const getValueFromLocalStorage = (key: string, defaultValue: any) => { | ||||||||||||||||||||||||||||||||||||||
| if (typeof window === undefined || typeof window === "undefined") return defaultValue; | ||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||
| const item = window.localStorage.getItem(key); | ||||||||||||||||||||||||||||||||||||||
|
|
@@ -11,6 +11,16 @@ const getValueFromLocalStorage = (key: string, defaultValue: any) => { | |||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| export const setValueIntoLocalStorage = (key: string, value: any) => { | ||||||||||||||||||||||||||||||||||||||
| if (typeof window === undefined || typeof window === "undefined") return false; | ||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why two checks?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was just a check that was copied over from the previous method getValueFromLocalStorage. The second check only should be good. Left the first one there as i was not sure, couldn't find references on the first check. Should i change it to only the second condition? |
||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||
| window.localStorage.setItem(key, JSON.stringify(value)); | ||||||||||||||||||||||||||||||||||||||
| return true; | ||||||||||||||||||||||||||||||||||||||
| } catch (error) { | ||||||||||||||||||||||||||||||||||||||
| return false; | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+14
to
+22
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Approve with a fix for the The However, there's an issue with the - if (typeof window === undefined || typeof window === "undefined") return false;
+ if (typeof window === "undefined") return false;This change addresses the static analysis warning and makes the check more concise and correct. Committable suggestion
Suggested change
ToolsBiome
|
||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| const useLocalStorage = <T,>(key: string, initialValue: T) => { | ||||||||||||||||||||||||||||||||||||||
| const [storedValue, setStoredValue] = useState<T | null>(() => getValueFromLocalStorage(key, initialValue)); | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -185,7 +185,7 @@ export class CycleIssues extends BaseIssuesStore implements ICycleIssues { | |||||
| // get params from pagination options | ||||||
| const params = this.issueFilterStore?.getFilterParams(options, cycleId, undefined, undefined, undefined); | ||||||
| // call the fetch issues API with the params | ||||||
| const response = await this.cycleService.getCycleIssues(workspaceSlug, projectId, cycleId, params, { | ||||||
| const response = await this.issueService.getIssues(workspaceSlug, projectId, params, { | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should add the cycle id to the params.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is being handled in the |
||||||
| signal: this.controller.signal, | ||||||
| }); | ||||||
|
Comment on lines
+188
to
190
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tip Codebase Verification Cycle ID Still Passed in getFilterParams The
Analysis chainLGTM! Verify cycle information in params The change aligns with the PR objective of modifying the Please ensure that the Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Description: Verify that the params object includes cycle information
# Test: Search for the getFilterParams method call in the file
rg --type typescript 'getFilterParams.*cycleId' web/core/store/issue/cycle/issue.store.ts
Length of output: 126 Script: #!/bin/bash
# Description: Verify that the params object includes cycle information
# Test: Search for the getFilterParams method call with cycleId in TypeScript files
rg 'getFilterParams.*cycleId' -g '*.ts' web/core/store/issue/cycle/issue.store.ts
Length of output: 195 |
||||||
|
|
||||||
|
|
@@ -233,7 +233,7 @@ export class CycleIssues extends BaseIssuesStore implements ICycleIssues { | |||||
| subGroupId | ||||||
| ); | ||||||
| // call the fetch issues API with the params for next page in issues | ||||||
| const response = await this.cycleService.getCycleIssues(workspaceSlug, projectId, cycleId, params); | ||||||
| const response = await this.issueService.getIssues(workspaceSlug, projectId, cycleId, params); | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Inconsistency in method call parameters While the change aligns with the PR objective of using the To maintain consistency, consider removing the - const response = await this.issueService.getIssues(workspaceSlug, projectId, cycleId, params);
+ const response = await this.issueService.getIssues(workspaceSlug, projectId, params);Also, ensure that the Committable suggestion
Suggested change
|
||||||
|
|
||||||
| // after the next page of issues are fetched, call the base method to process the response | ||||||
| this.onfetchNexIssues(response, groupId, subGroupId); | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,4 +1,4 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { makeObservable } from "mobx"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { makeObservable, observable } from "mobx"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { computedFn } from "mobx-utils"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // types | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { TIssue } from "@plane/types"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -32,11 +32,13 @@ export interface IIssueStoreActions { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export interface IIssueStore extends IIssueStoreActions { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| isFetchingIssueDetails: boolean; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // helper methods | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| getIssueById: (issueId: string) => TIssue | undefined; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export class IssueStore implements IIssueStore { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| isFetchingIssueDetails: boolean = false; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // root store | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| rootIssueDetailStore: IIssueDetail; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // services | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -45,7 +47,9 @@ export class IssueStore implements IIssueStore { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| issueDraftService; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| constructor(rootStore: IIssueDetail) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| makeObservable(this, {}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| makeObservable(this, { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| isFetchingIssueDetails: observable.ref, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // root store | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| this.rootIssueDetailStore = rootStore; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // services | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -66,7 +70,9 @@ export class IssueStore implements IIssueStore { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| expand: "issue_reactions,issue_attachment,issue_link,parent", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let issue: TIssue; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let issue: TIssue | undefined; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| this.isFetchingIssueDetails = true; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure isFetchingIssueDetails is Reset on Error
Apply this diff to fix the issue: fetchIssue = async (workspaceSlug: string, projectId: string, issueId: string, issueType = "DEFAULT") => {
const query = {
expand: "issue_reactions,issue_attachment,issue_link,parent",
};
let issue: TIssue | undefined;
this.isFetchingIssueDetails = true;
+ try {
if (issueType === "ARCHIVED")
issue = await this.issueArchiveService.retrieveArchivedIssue(workspaceSlug, projectId, issueId, query);
else if (issueType === "DRAFT")
issue = await this.issueDraftService.getDraftIssueById(workspaceSlug, projectId, issueId, query);
else
issue = await this.issueService.retrieve(workspaceSlug, projectId, issueId, query);
if (!issue) throw new Error("Issue not found");
this.addIssueToStore(issue);
+ } finally {
+ this.isFetchingIssueDetails = false;
+ }
return issue;
};Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (issueType === "ARCHIVED") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| issue = await this.issueArchiveService.retrieveArchivedIssue(workspaceSlug, projectId, issueId, query); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -76,38 +82,7 @@ export class IssueStore implements IIssueStore { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!issue) throw new Error("Issue not found"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const issuePayload: TIssue = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| id: issue?.id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sequence_id: issue?.sequence_id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| name: issue?.name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| description_html: issue?.description_html, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sort_order: issue?.sort_order, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| state_id: issue?.state_id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| priority: issue?.priority, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| label_ids: issue?.label_ids, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assignee_ids: issue?.assignee_ids, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| estimate_point: issue?.estimate_point, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sub_issues_count: issue?.sub_issues_count, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| attachment_count: issue?.attachment_count, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| link_count: issue?.link_count, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| project_id: issue?.project_id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| parent_id: issue?.parent_id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cycle_id: issue?.cycle_id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| module_ids: issue?.module_ids, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type_id: issue?.type_id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| created_at: issue?.created_at, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| updated_at: issue?.updated_at, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| start_date: issue?.start_date, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| target_date: issue?.target_date, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| completed_at: issue?.completed_at, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| archived_at: issue?.archived_at, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| created_by: issue?.created_by, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| updated_by: issue?.updated_by, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| is_draft: issue?.is_draft, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| is_subscribed: issue?.is_subscribed, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| this.rootIssueDetailStore.rootIssueStore.issues.addIssue([issuePayload]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| this.addIssueToStore(issue); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // store handlers from issue detail | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // parent | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -150,6 +125,44 @@ export class IssueStore implements IIssueStore { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return issue; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| addIssueToStore = (issue: TIssue) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const issuePayload: TIssue = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| id: issue?.id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sequence_id: issue?.sequence_id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| name: issue?.name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| description_html: issue?.description_html, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sort_order: issue?.sort_order, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| state_id: issue?.state_id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| priority: issue?.priority, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| label_ids: issue?.label_ids, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assignee_ids: issue?.assignee_ids, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| estimate_point: issue?.estimate_point, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sub_issues_count: issue?.sub_issues_count, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| attachment_count: issue?.attachment_count, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| link_count: issue?.link_count, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| project_id: issue?.project_id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| parent_id: issue?.parent_id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cycle_id: issue?.cycle_id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| module_ids: issue?.module_ids, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type_id: issue?.type_id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| created_at: issue?.created_at, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| updated_at: issue?.updated_at, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| start_date: issue?.start_date, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| target_date: issue?.target_date, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| completed_at: issue?.completed_at, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| archived_at: issue?.archived_at, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| created_by: issue?.created_by, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| updated_by: issue?.updated_by, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| is_draft: issue?.is_draft, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| is_subscribed: issue?.is_subscribed, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+128
to
+158
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Simplify issuePayload Creation Using Object Spread Operator Manually copying each property from Apply this diff to refactor: addIssueToStore = (issue: TIssue) => {
- const issuePayload: TIssue = {
- id: issue?.id,
- sequence_id: issue?.sequence_id,
- name: issue?.name,
- description_html: issue?.description_html,
- sort_order: issue?.sort_order,
- state_id: issue?.state_id,
- priority: issue?.priority,
- label_ids: issue?.label_ids,
- assignee_ids: issue?.assignee_ids,
- estimate_point: issue?.estimate_point,
- sub_issues_count: issue?.sub_issues_count,
- attachment_count: issue?.attachment_count,
- link_count: issue?.link_count,
- project_id: issue?.project_id,
- parent_id: issue?.parent_id,
- cycle_id: issue?.cycle_id,
- module_ids: issue?.module_ids,
- type_id: issue?.type_id,
- created_at: issue?.created_at,
- updated_at: issue?.updated_at,
- start_date: issue?.start_date,
- target_date: issue?.target_date,
- completed_at: issue?.completed_at,
- archived_at: issue?.archived_at,
- created_by: issue?.created_by,
- updated_by: issue?.updated_by,
- is_draft: issue?.is_draft,
- is_subscribed: issue?.is_subscribed,
- };
+ const issuePayload: TIssue = { ...issue };This refactor improves maintainability by reducing code duplication and potential for errors. Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| this.rootIssueDetailStore.rootIssueStore.issues.addIssue([issuePayload]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| this.isFetchingIssueDetails = false; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return issuePayload; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| updateIssue = async (workspaceSlug: string, projectId: string, issueId: string, data: Partial<TIssue>) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await this.rootIssueDetailStore.rootIssueStore.projectIssues.updateIssue(workspaceSlug, projectId, issueId, data); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await this.rootIssueDetailStore.activity.fetchActivities(workspaceSlug, projectId, issueId); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tip
Codebase Verification
Inconsistent Naming Conventions Identified
The enums
EIssueGroupBYServerToPropertyandEIssueGroupByToServerOptionsexhibit inconsistent naming conventions, which can lead to confusion and maintenance challenges.EIssueGroupBYServerToPropertyis defined inpackages/constants/issue.tsbut does not appear to be used elsewhere in the codebase.labels__idmaps tolabel_idsinstead oflabels__idassignees__idmaps toassignee_idsinstead ofassignees__idissue_module__module_idmaps tomodule_idsinstead ofissue_module__module_idRecommendation:
EIssueGroupBYServerToPropertyandEIssueGroupByToServerOptions.EIssueGroupBYServerToPropertyenum if it is deprecated to maintain clarity.Analysis chain
Verify naming consistency with existing enums
There are some differences in naming conventions between
EIssueGroupBYServerToPropertyandEIssueGroupByToServerOptions:labels__idmaps tolabel_idsinstead oflabels__idassignees__idmaps toassignee_idsinstead ofassignees__idissue_module__module_idmaps tomodule_idsinstead ofissue_module__module_idPlease verify if these differences are intentional. If not, consider aligning the naming conventions to maintain consistency across the codebase.
To help verify the usage of these properties, you can run the following script:
This script will help identify how the new enum is being used in comparison to the existing ones, and whether the naming differences are consistent throughout the codebase.
Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 627
Script:
Length of output: 24627