-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[WEB-2625] chore: workspace favorite and draft improvement #5855
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
9049146
0d0d59d
70e7c05
227e5aa
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 | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -139,6 +139,13 @@ export class WorkspaceDraftIssues implements IWorkspaceDraftIssues { | |||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| private updateWorkspaceUserDraftIssueCount(workspaceSlug: string, increment: number) { | ||||||||||||||||||||||||||||
| const workspaceUserInfo = this.issueStore.rootStore.user.permission.workspaceUserInfo; | ||||||||||||||||||||||||||||
| const currentCount = workspaceUserInfo[workspaceSlug]?.draft_issue_count ?? 0; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| set(workspaceUserInfo, [workspaceSlug, "draft_issue_count"], currentCount + increment); | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
|
Comment on lines
+142
to
+148
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 The Apply this diff to enforce a non-negative private updateWorkspaceUserDraftIssueCount(workspaceSlug: string, increment: number) {
const workspaceUserInfo = this.issueStore.rootStore.user.permission.workspaceUserInfo;
const currentCount = workspaceUserInfo[workspaceSlug]?.draft_issue_count ?? 0;
+ const updatedCount = Math.max(0, currentCount + increment);
+ set(workspaceUserInfo, [workspaceSlug, "draft_issue_count"], updatedCount);
- set(workspaceUserInfo, [workspaceSlug, "draft_issue_count"], currentCount + increment);
}📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||
| // computed | ||||||||||||||||||||||||||||
| get issueIds() { | ||||||||||||||||||||||||||||
| const workspaceSlug = this.issueStore.workspaceSlug; | ||||||||||||||||||||||||||||
|
|
@@ -259,6 +266,8 @@ export class WorkspaceDraftIssues implements IWorkspaceDraftIssues { | |||||||||||||||||||||||||||
| total_count: this.paginationInfo.total_count + 1, | ||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| // Update draft issue count in workspaceUserInfo | ||||||||||||||||||||||||||||
| this.updateWorkspaceUserDraftIssueCount(workspaceSlug, 1); | ||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
|
|
@@ -310,6 +319,8 @@ export class WorkspaceDraftIssues implements IWorkspaceDraftIssues { | |||||||||||||||||||||||||||
| total_count: this.paginationInfo.total_count - 1, | ||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| // Update draft issue count in workspaceUserInfo | ||||||||||||||||||||||||||||
| this.updateWorkspaceUserDraftIssueCount(workspaceSlug, -1); | ||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| this.loader = undefined; | ||||||||||||||||||||||||||||
|
|
@@ -337,6 +348,8 @@ export class WorkspaceDraftIssues implements IWorkspaceDraftIssues { | |||||||||||||||||||||||||||
| total_count: this.paginationInfo.total_count - 1, | ||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| // Update draft issue count in workspaceUserInfo | ||||||||||||||||||||||||||||
| this.updateWorkspaceUserDraftIssueCount(workspaceSlug, -1); | ||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| this.loader = undefined; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
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.
🛠️ Refactor suggestion
Simplify the query by removing unnecessary
SubqueryandOuterRefSince you are fetching a single
WorkspaceMemberobject for the current user and workspace, using aSubqueryandOuterRefadds unnecessary complexity. You can simplify the code by directly querying the count ofDraftIssueobjects and assigning it to theWorkspaceMemberinstance.Apply this diff to simplify the code:
Note: Ensure that the
WorkspaceMemberMeSerializeris updated to handle thedraft_issue_countattribute appropriately. You might need to modify the serializer to include this field if it's not already defined.📝 Committable suggestion