From fb4ac91f22b7abf548257aec36702391653ed944 Mon Sep 17 00:00:00 2001 From: rahulramesha Date: Fri, 22 Mar 2024 18:17:27 +0530 Subject: [PATCH] fix group by bugs --- .../calendar/base-calendar-root.tsx | 18 +++- .../issue-layouts/gantt/base-gantt-root.tsx | 2 +- .../issues/issue-layouts/issue-layout-HOC.tsx | 2 +- .../issue-layouts/kanban/blocks-list.tsx | 7 +- .../issues/issue-layouts/kanban/default.tsx | 20 ++-- .../issue-layouts/kanban/kanban-group.tsx | 20 ++-- .../issues/issue-layouts/kanban/swimlanes.tsx | 77 ++++++++------- .../issue-layouts/list/base-list-root.tsx | 18 +++- .../roots/all-issue-layout-root.tsx | 2 +- .../spreadsheet/base-spreadsheet-root.tsx | 2 +- web/store/issue/archived/issue.store.ts | 2 +- web/store/issue/cycle/issue.store.ts | 2 +- web/store/issue/draft/issue.store.ts | 2 +- web/store/issue/helpers/base-issues.store.ts | 95 ++++++++++++------- web/store/issue/module/issue.store.ts | 2 +- web/store/issue/profile/issue.store.ts | 2 +- web/store/issue/project-views/issue.store.ts | 2 +- web/store/issue/project/issue.store.ts | 2 +- web/store/issue/workspace/issue.store.ts | 2 +- 19 files changed, 173 insertions(+), 106 deletions(-) diff --git a/web/components/issues/issue-layouts/calendar/base-calendar-root.tsx b/web/components/issues/issue-layouts/calendar/base-calendar-root.tsx index 1f7afe5e0..1c80e81d7 100644 --- a/web/components/issues/issue-layouts/calendar/base-calendar-root.tsx +++ b/web/components/issues/issue-layouts/calendar/base-calendar-root.tsx @@ -119,6 +119,20 @@ export const BaseCalendarRoot = observer((props: IBaseCalendarRoot) => { [fetchNextIssues] ); + const getPaginationData = useCallback( + (groupId: string | undefined) => { + return issues?.getPaginationData(groupId, undefined); + }, + [issues?.getPaginationData] + ); + + const getGroupIssueCount = useCallback( + (groupId: string | undefined) => { + return issues?.getGroupIssueCount(groupId, undefined, false); + }, + [issues?.getGroupIssueCount] + ); + return (
@@ -145,8 +159,8 @@ export const BaseCalendarRoot = observer((props: IBaseCalendarRoot) => { /> )} loadMoreIssues={loadMoreIssues} - getPaginationData={issues.getPaginationData} - getGroupIssueCount={issues.getGroupIssueCount} + getPaginationData={getPaginationData} + getGroupIssueCount={getGroupIssueCount} addIssuesToView={addIssuesToView} quickAddCallback={issues.quickAddIssue} viewId={viewId} diff --git a/web/components/issues/issue-layouts/gantt/base-gantt-root.tsx b/web/components/issues/issue-layouts/gantt/base-gantt-root.tsx index 518e33c46..8e26fc331 100644 --- a/web/components/issues/issue-layouts/gantt/base-gantt-root.tsx +++ b/web/components/issues/issue-layouts/gantt/base-gantt-root.tsx @@ -49,7 +49,7 @@ export const BaseGanttRoot: React.FC = observer((props: IBaseGan }); const issuesIds = (issues.groupedIssueIds?.[ALL_ISSUES] as string[]) ?? []; - const nextPageResults = issues.getPaginationData(ALL_ISSUES)?.nextPageResults; + const nextPageResults = issues.getPaginationData(undefined, undefined)?.nextPageResults; const { enableIssueCreation } = issues?.viewFlags || {}; diff --git a/web/components/issues/issue-layouts/issue-layout-HOC.tsx b/web/components/issues/issue-layouts/issue-layout-HOC.tsx index dd6384b4f..cb5b7e414 100644 --- a/web/components/issues/issue-layouts/issue-layout-HOC.tsx +++ b/web/components/issues/issue-layouts/issue-layout-HOC.tsx @@ -44,7 +44,7 @@ export const IssueLayoutHOC = observer((props: Props) => { return ; } - if (issues.getGroupIssueCount(ALL_ISSUES) === 0) { + if (issues.getGroupIssueCount(undefined, undefined, false) === 0) { return ; } diff --git a/web/components/issues/issue-layouts/kanban/blocks-list.tsx b/web/components/issues/issue-layouts/kanban/blocks-list.tsx index 607a642e1..15e492179 100644 --- a/web/components/issues/issue-layouts/kanban/blocks-list.tsx +++ b/web/components/issues/issue-layouts/kanban/blocks-list.tsx @@ -2,6 +2,7 @@ import { MutableRefObject, memo } from "react"; //types import { KanbanIssueBlock } from "components/issues"; import { TIssue, IIssueDisplayProperties, IIssueMap } from "@plane/types"; +import { observer } from "mobx-react"; // components interface IssueBlocksListProps { @@ -21,7 +22,7 @@ interface IssueBlocksListProps { isDragStarted?: boolean; } -const KanbanIssueBlocksListMemo: React.FC = (props) => { +export const KanbanIssueBlocksList: React.FC = observer((props) => { const { sub_group_id, columnId, @@ -71,6 +72,4 @@ const KanbanIssueBlocksListMemo: React.FC = (props) => { ) : null} ); -}; - -export const KanbanIssueBlocksList = memo(KanbanIssueBlocksListMemo); +}); diff --git a/web/components/issues/issue-layouts/kanban/default.tsx b/web/components/issues/issue-layouts/kanban/default.tsx index be8820124..7967a2316 100644 --- a/web/components/issues/issue-layouts/kanban/default.tsx +++ b/web/components/issues/issue-layouts/kanban/default.tsx @@ -34,8 +34,12 @@ import { KanbanStoreType } from "./base-kanban-root"; export interface IGroupByKanBan { issuesMap: IIssueMap; groupedIssueIds: TGroupedIssues | TSubGroupedIssues; - getGroupIssueCount: (groupId: string | undefined) => number | undefined; - getPaginationData: (groupId: string | undefined) => TPaginationData | undefined; + getGroupIssueCount: ( + groupId: string | undefined, + subGroupId: string | undefined, + isSubGroupCumulative: boolean + ) => number | undefined; + getPaginationData: (groupId: string | undefined, subGroupId: string | undefined) => TPaginationData | undefined; displayProperties: IIssueDisplayProperties | undefined; sub_group_by: string | null; group_by: string | null; @@ -113,7 +117,7 @@ const GroupByKanBan: React.FC = observer((props) => { if (!list) return null; - const groupWithIssues = list.filter((_list) => (getGroupIssueCount(_list.id) ?? 0) > 0); + const groupWithIssues = list.filter((_list) => (getGroupIssueCount(_list.id, undefined, false) ?? 0) > 0); const groupList = showEmptyGroup ? list : groupWithIssues; @@ -149,7 +153,7 @@ const GroupByKanBan: React.FC = observer((props) => { column_id={_list.id} icon={_list.icon} title={_list.name} - count={getGroupIssueCount(_list.id) ?? 0} + count={getGroupIssueCount(_list.id, undefined, false) ?? 0} issuePayload={_list.payload} disableIssueCreation={disableIssueCreation || isGroupByCreatedBy} storeType={storeType} @@ -196,8 +200,12 @@ const GroupByKanBan: React.FC = observer((props) => { export interface IKanBan { issuesMap: IIssueMap; groupedIssueIds: TGroupedIssues | TSubGroupedIssues; - getGroupIssueCount: (groupId: string | undefined) => number | undefined; - getPaginationData: (groupId: string | undefined) => TPaginationData | undefined; + getPaginationData: (groupId: string | undefined, subGroupId: string | undefined) => TPaginationData | undefined; + getGroupIssueCount: ( + groupId: string | undefined, + subGroupId: string | undefined, + isSubGroupCumulative: boolean + ) => number | undefined; displayProperties: IIssueDisplayProperties | undefined; sub_group_by: string | null; group_by: string | null; diff --git a/web/components/issues/issue-layouts/kanban/kanban-group.tsx b/web/components/issues/issue-layouts/kanban/kanban-group.tsx index 82935463b..30f7ce75f 100644 --- a/web/components/issues/issue-layouts/kanban/kanban-group.tsx +++ b/web/components/issues/issue-layouts/kanban/kanban-group.tsx @@ -22,8 +22,12 @@ interface IKanbanGroup { issuesMap: IIssueMap; peekIssueId?: string; groupedIssueIds: TGroupedIssues | TSubGroupedIssues; - getGroupIssueCount: (groupId: string | undefined) => number | undefined; - getPaginationData: (groupId: string | undefined) => TPaginationData | undefined; + getPaginationData: (groupId: string | undefined, subGroupId: string | undefined) => TPaginationData | undefined; + getGroupIssueCount: ( + groupId: string | undefined, + subGroupId: string | undefined, + isSubGroupCumulative: boolean + ) => number | undefined; displayProperties: IIssueDisplayProperties | undefined; sub_group_by: string | null; group_by: string | null; @@ -135,14 +139,14 @@ export const KanbanGroup = observer((props: IKanbanGroup) => { const isSubGroup = !!sub_group_id && sub_group_id !== "null"; const issueIds = isSubGroup - ? (groupedIssueIds as TSubGroupedIssues)[groupId][sub_group_id] - : (groupedIssueIds as TGroupedIssues)[groupId]; + ? (groupedIssueIds as TSubGroupedIssues)?.[groupId]?.[sub_group_id] + : (groupedIssueIds as TGroupedIssues)?.[groupId]; - const groupIssueCount = isSubGroup ? getGroupIssueCount(sub_group_id) : getGroupIssueCount(groupId); + if (!issueIds) return null; - const nextPageResults = isSubGroup - ? getPaginationData(sub_group_id)?.nextPageResults - : getPaginationData(groupId)?.nextPageResults; + const groupIssueCount = getGroupIssueCount(groupId, sub_group_id, false); + + const nextPageResults = getPaginationData(groupId, sub_group_id)?.nextPageResults; const shouldLoadMore = nextPageResults === undefined && groupIssueCount !== undefined diff --git a/web/components/issues/issue-layouts/kanban/swimlanes.tsx b/web/components/issues/issue-layouts/kanban/swimlanes.tsx index 3fe0770ad..42be7a936 100644 --- a/web/components/issues/issue-layouts/kanban/swimlanes.tsx +++ b/web/components/issues/issue-layouts/kanban/swimlanes.tsx @@ -11,7 +11,6 @@ import { IIssueMap, TSubGroupedIssues, TIssueKanbanFilters, - TGroupedIssueCount, TPaginationData, } from "@plane/types"; import { getGroupByColumns } from "../utils"; @@ -23,7 +22,11 @@ import { KanbanStoreType } from "./base-kanban-root"; // constants interface ISubGroupSwimlaneHeader { - getGroupIssueCount: (groupId: string | undefined) => number | undefined; + getGroupIssueCount: ( + groupId: string | undefined, + subGroupId: string | undefined, + isSubGroupCumulative: boolean + ) => number | undefined; sub_group_by: string | null; group_by: string | null; list: IGroupByColumn[]; @@ -32,42 +35,40 @@ interface ISubGroupSwimlaneHeader { storeType: KanbanStoreType; } -const SubGroupSwimlaneHeader: React.FC = ({ - getGroupIssueCount, - sub_group_by, - group_by, - storeType, - list, - kanbanFilters, - handleKanbanFilters, -}) => ( -
- {list && - list.length > 0 && - list.map((_list: IGroupByColumn) => ( -
- -
- ))} -
+const SubGroupSwimlaneHeader: React.FC = observer( + ({ getGroupIssueCount, sub_group_by, group_by, storeType, list, kanbanFilters, handleKanbanFilters }) => ( +
+ {list && + list.length > 0 && + list.map((_list: IGroupByColumn) => ( +
+ +
+ ))} +
+ ) ); interface ISubGroupSwimlane extends ISubGroupSwimlaneHeader { issuesMap: IIssueMap; groupedIssueIds: TGroupedIssues | TSubGroupedIssues; - getGroupIssueCount: (groupId: string | undefined) => number | undefined; - getPaginationData: (groupId: string | undefined) => TPaginationData | undefined; + getPaginationData: (groupId: string | undefined, subGroupId: string | undefined) => TPaginationData | undefined; + getGroupIssueCount: ( + groupId: string | undefined, + subGroupId: string | undefined, + isSubGroupCumulative: boolean + ) => number | undefined; showEmptyGroup: boolean; displayProperties: IIssueDisplayProperties | undefined; updateIssue: @@ -123,7 +124,7 @@ const SubGroupSwimlane: React.FC = observer((props) => { {list && list.length > 0 && list.map((_list: any) => { - const issueCount = getGroupIssueCount(_list.id) ?? 0; + const issueCount = getGroupIssueCount(undefined, _list.id, true) ?? 0; return (
@@ -178,8 +179,12 @@ const SubGroupSwimlane: React.FC = observer((props) => { export interface IKanBanSwimLanes { issuesMap: IIssueMap; groupedIssueIds: TGroupedIssues | TSubGroupedIssues; - getGroupIssueCount: (groupId: string | undefined) => number | undefined; - getPaginationData: (groupId: string | undefined) => TPaginationData | undefined; + getPaginationData: (groupId: string | undefined, subGroupId: string | undefined) => TPaginationData | undefined; + getGroupIssueCount: ( + groupId: string | undefined, + subGroupId: string | undefined, + isSubGroupCumulative: boolean + ) => number | undefined; displayProperties: IIssueDisplayProperties | undefined; sub_group_by: string | null; group_by: string | null; diff --git a/web/components/issues/issue-layouts/list/base-list-root.tsx b/web/components/issues/issue-layouts/list/base-list-root.tsx index 794f3a26c..0123e2ac7 100644 --- a/web/components/issues/issue-layouts/list/base-list-root.tsx +++ b/web/components/issues/issue-layouts/list/base-list-root.tsx @@ -105,6 +105,20 @@ export const BaseListRoot = observer((props: IBaseListRoot) => { [fetchNextIssues] ); + const getPaginationData = useCallback( + (groupId?: string) => { + return issues?.getPaginationData(groupId, undefined); + }, + [issues?.getPaginationData] + ); + + const getGroupIssueCount = useCallback( + (groupId?: string) => { + return issues?.getGroupIssueCount(groupId, undefined, false); + }, + [issues?.getGroupIssueCount] + ); + return (
@@ -118,8 +132,8 @@ export const BaseListRoot = observer((props: IBaseListRoot) => { loadMoreIssues={loadMoreIssues} showEmptyGroup={showEmptyGroup} viewId={viewId} - getPaginationData={issues.getPaginationData} - getGroupIssueCount={issues.getGroupIssueCount} + getPaginationData={getPaginationData} + getGroupIssueCount={getGroupIssueCount} quickAddCallback={issues?.quickAddIssue} enableIssueQuickAdd={!!enableQuickAdd} canEditProperties={canEditProperties} diff --git a/web/components/issues/issue-layouts/roots/all-issue-layout-root.tsx b/web/components/issues/issue-layouts/roots/all-issue-layout-root.tsx index 5e886d554..d72e9f300 100644 --- a/web/components/issues/issue-layouts/roots/all-issue-layout-root.tsx +++ b/web/components/issues/issue-layouts/roots/all-issue-layout-root.tsx @@ -161,7 +161,7 @@ export const AllIssueLayoutRoot: React.FC = observer(() => { } const issueIds = groupedIssueIds[ALL_ISSUES]; - const nextPageResults = getPaginationData(ALL_ISSUES)?.nextPageResults; + const nextPageResults = getPaginationData(ALL_ISSUES, undefined)?.nextPageResults; const emptyStateType = (workspaceProjectIds ?? []).length > 0 ? `workspace-${globalViewId}` : EmptyStateType.WORKSPACE_NO_PROJECTS; diff --git a/web/components/issues/issue-layouts/spreadsheet/base-spreadsheet-root.tsx b/web/components/issues/issue-layouts/spreadsheet/base-spreadsheet-root.tsx index 3f1008300..847c3f3dd 100644 --- a/web/components/issues/issue-layouts/spreadsheet/base-spreadsheet-root.tsx +++ b/web/components/issues/issue-layouts/spreadsheet/base-spreadsheet-root.tsx @@ -74,7 +74,7 @@ export const BaseSpreadsheetRoot = observer((props: IBaseSpreadsheetRoot) => { ); const issueIds = issues.groupedIssueIds?.[ALL_ISSUES] ?? []; - const nextPageResults = issues.getPaginationData(ALL_ISSUES)?.nextPageResults; + const nextPageResults = issues.getPaginationData(ALL_ISSUES, undefined)?.nextPageResults; const handleDisplayFiltersUpdate = useCallback( (updatedDisplayFilter: Partial) => { diff --git a/web/store/issue/archived/issue.store.ts b/web/store/issue/archived/issue.store.ts index 0252742ed..5dff1d980 100644 --- a/web/store/issue/archived/issue.store.ts +++ b/web/store/issue/archived/issue.store.ts @@ -83,7 +83,7 @@ export class ArchivedIssues extends BaseIssuesStore implements IArchivedIssues { }; fetchNextIssues = async (workspaceSlug: string, projectId: string, groupId?: string, subGroupId?: string) => { - const cursorObject = this.getPaginationData(subGroupId ?? groupId); + const cursorObject = this.getPaginationData(groupId, subGroupId); if (!this.paginationOptions || (cursorObject && !cursorObject?.nextPageResults)) return; try { this.loader = "pagination"; diff --git a/web/store/issue/cycle/issue.store.ts b/web/store/issue/cycle/issue.store.ts index 275022fa3..699ee7ae2 100644 --- a/web/store/issue/cycle/issue.store.ts +++ b/web/store/issue/cycle/issue.store.ts @@ -135,7 +135,7 @@ export class CycleIssues extends BaseIssuesStore implements ICycleIssues { groupId?: string, subGroupId?: string ) => { - const cursorObject = this.getPaginationData(subGroupId ?? groupId); + const cursorObject = this.getPaginationData(groupId, subGroupId); if (!this.paginationOptions || (cursorObject && !cursorObject?.nextPageResults)) return; try { this.loader = "pagination"; diff --git a/web/store/issue/draft/issue.store.ts b/web/store/issue/draft/issue.store.ts index e55162d83..56196e24f 100644 --- a/web/store/issue/draft/issue.store.ts +++ b/web/store/issue/draft/issue.store.ts @@ -80,7 +80,7 @@ export class DraftIssues extends BaseIssuesStore implements IDraftIssues { }; fetchNextIssues = async (workspaceSlug: string, projectId: string, groupId?: string, subGroupId?: string) => { - const cursorObject = this.getPaginationData(subGroupId ?? groupId); + const cursorObject = this.getPaginationData(groupId, subGroupId); if (!this.paginationOptions || (cursorObject && !cursorObject?.nextPageResults)) return; try { this.loader = "pagination"; diff --git a/web/store/issue/helpers/base-issues.store.ts b/web/store/issue/helpers/base-issues.store.ts index 2b2e90869..4cbb4ee61 100644 --- a/web/store/issue/helpers/base-issues.store.ts +++ b/web/store/issue/helpers/base-issues.store.ts @@ -58,8 +58,12 @@ export interface IBaseIssuesStore { issueDisplayFiltersDefaultData(groupBy: string | null): string[]; issuesSortWithOrderBy(issueIds: string[], key: Partial): string[]; getGroupArray(value: boolean | number | string | string[] | null, isDate?: boolean): string[]; - getPaginationData(groupId: string | undefined): TPaginationData | undefined; - getGroupIssueCount: (groupId: string | undefined) => number | undefined; + getPaginationData(groupId: string | undefined, subGroupId: string | undefined): TPaginationData | undefined; + getGroupIssueCount: ( + groupId: string | undefined, + subGroupId: string | undefined, + isSubGroupCumulative: boolean + ) => number | undefined; } const ISSUE_FILTER_DEFAULT_DATA: Record = { @@ -144,14 +148,20 @@ export class BaseIssuesStore implements IBaseIssuesStore { const displayFilters = this.issueFilterStore?.issueFilters?.displayFilters; if (!displayFilters) return; - return displayFilters?.group_by; + const layout = displayFilters?.layout; + + return layout === "calendar" + ? "target_date" + : ["list", "kanban"]?.includes(layout) + ? displayFilters?.group_by + : undefined; } get subGroupBy() { const displayFilters = this.issueFilterStore?.issueFilters?.displayFilters; if (!displayFilters || displayFilters.group_by === displayFilters.sub_group_by) return; - return displayFilters?.sub_group_by; + return displayFilters?.layout === "kanban" ? displayFilters?.sub_group_by : undefined; } get issueGroupKey() { @@ -208,19 +218,22 @@ export class BaseIssuesStore implements IBaseIssuesStore { const issueGroupCount = groupedIssueCount[ALL_ISSUES]; const issuesPath = [groupId]; - if (!subGroupId) { - set(this.groupedIssueCount, [groupId], issueGroupCount); - } + if (subGroupId) issuesPath.push(subGroupId); + + set(this.groupedIssueCount, [this.getGroupKey(groupId, subGroupId)], issueGroupCount); this.updateIssueGroup(issueGroup, issuesPath); return; } + set(this.groupedIssueCount, [ALL_ISSUES], groupedIssueCount[ALL_ISSUES]); + for (const groupId in groupedIssues) { const issueGroup = groupedIssues[groupId]; const issueGroupCount = groupedIssueCount[groupId]; set(this.groupedIssueCount, [groupId], issueGroupCount); + const shouldContinue = this.updateIssueGroup(issueGroup, [groupId]); if (shouldContinue) continue; @@ -228,7 +241,7 @@ export class BaseIssuesStore implements IBaseIssuesStore { const issueSubGroup = (issueGroup as TGroupedIssues)[subGroupId]; const issueSubGroupCount = groupedIssueCount[subGroupId]; - set(this.groupedIssueCount, [subGroupId], issueSubGroupCount); + set(this.groupedIssueCount, [this.getGroupKey(groupId, subGroupId)], issueSubGroupCount); this.updateIssueGroup(issueSubGroup, [groupId, subGroupId]); } } @@ -421,22 +434,23 @@ export class BaseIssuesStore implements IBaseIssuesStore { updateIssueCount(path: string[], increment: number) { const [groupId, subGroupId] = path; - if (subGroupId) { - const subGroupIssueCount = get(this.groupedIssueCount, [subGroupId]); + if (subGroupId && groupId) { + const groupKey = this.getGroupKey(groupId, subGroupId); + const subGroupIssueCount = get(this.groupedIssueCount, groupKey); - set(this.groupedIssueCount, [subGroupId], subGroupIssueCount + increment); + set(this.groupedIssueCount, groupKey, subGroupIssueCount + increment); } if (groupId) { const groupIssueCount = get(this.groupedIssueCount, [groupId]); - set(this.groupedIssueCount, [groupId], groupIssueCount + increment); + set(this.groupedIssueCount, groupId, groupIssueCount + increment); } if (groupId !== ALL_ISSUES) { const totalIssueCount = get(this.groupedIssueCount, [ALL_ISSUES]); - set(this.groupedIssueCount, [ALL_ISSUES], totalIssueCount + increment); + set(this.groupedIssueCount, ALL_ISSUES, totalIssueCount + increment); } } @@ -909,6 +923,8 @@ export class BaseIssuesStore implements IBaseIssuesStore { const groupedIssues: TGroupedIssues | TSubGroupedIssues = {}; const groupedIssueCount: TGroupedIssueCount = {}; + set(groupedIssueCount, [ALL_ISSUES], issueResponse.total_count); + for (const groupId in issueResult) { const groupIssuesObject = issueResult[groupId]; const groupIssueResult = groupIssuesObject?.results; @@ -933,7 +949,7 @@ export class BaseIssuesStore implements IBaseIssuesStore { if (!subGroupIssueResult) continue; - set(groupedIssueCount, [subGroupId], subGroupIssuesObject.total_results); + set(groupedIssueCount, [this.getGroupKey(groupId, subGroupId)], subGroupIssuesObject.total_results); if (Array.isArray(subGroupIssueResult)) { issueList.push(...subGroupIssueResult); @@ -964,32 +980,39 @@ export class BaseIssuesStore implements IBaseIssuesStore { nextPageResults, }; - if (groupId && subGroupId) { - set(this.issuePaginationData, [subGroupId], cursorObject); - return; - } - - if (groupId) { - set(this.issuePaginationData, [groupId], cursorObject); - return; - } - - set(this.issuePaginationData, [ALL_ISSUES], cursorObject); + set(this.issuePaginationData, [this.getGroupKey(groupId, subGroupId)], cursorObject); } - getPaginationData = computedFn((groupId: string | undefined): TPaginationData | undefined => { - if (groupId) { - return get(this.issuePaginationData, [groupId]); + getGroupKey(groupId?: string, subGroupId?: string) { + if (groupId && subGroupId) return `${groupId}_${subGroupId}`; + + if (groupId) return groupId; + + return ALL_ISSUES; + } + + getPaginationData = computedFn( + (groupId: string | undefined, subGroupId: string | undefined): TPaginationData | undefined => { + return get(this.issuePaginationData, [this.getGroupKey(groupId, subGroupId)]); } + ); - return get(this.issuePaginationData, [ALL_ISSUES]); - }); + getGroupIssueCount = computedFn( + ( + groupId: string | undefined, + subGroupId: string | undefined, + isSubGroupCumulative: boolean + ): number | undefined => { + if (isSubGroupCumulative && subGroupId) { + const groupIssuesKeys = Object.keys(this.groupedIssueCount); + let subGroupCumulativeCount = 0; - getGroupIssueCount = computedFn((groupId: string | undefined): number | undefined => { - if (groupId) { - return get(this.groupedIssueCount, [groupId]); + for (const groupKey of groupIssuesKeys) { + if (groupKey.includes(subGroupId)) subGroupCumulativeCount += this.groupedIssueCount[groupKey]; + } + } + + return get(this.groupedIssueCount, [this.getGroupKey(groupId, subGroupId)]); } - - return get(this.groupedIssueCount, [ALL_ISSUES]); - }); + ); } diff --git a/web/store/issue/module/issue.store.ts b/web/store/issue/module/issue.store.ts index d471795fe..da60b94e4 100644 --- a/web/store/issue/module/issue.store.ts +++ b/web/store/issue/module/issue.store.ts @@ -135,7 +135,7 @@ export class ModuleIssues extends BaseIssuesStore implements IModuleIssues { groupId?: string, subGroupId?: string ) => { - const cursorObject = this.getPaginationData(subGroupId ?? groupId); + const cursorObject = this.getPaginationData(groupId, subGroupId); if (!this.paginationOptions || (cursorObject && !cursorObject?.nextPageResults)) return; try { this.loader = "pagination"; diff --git a/web/store/issue/profile/issue.store.ts b/web/store/issue/profile/issue.store.ts index 8dc984096..1a6d74130 100644 --- a/web/store/issue/profile/issue.store.ts +++ b/web/store/issue/profile/issue.store.ts @@ -122,7 +122,7 @@ export class ProfileIssues extends BaseIssuesStore implements IProfileIssues { }; fetchNextIssues = async (workspaceSlug: string, userId: string, groupId?: string, subGroupId?: string) => { - const cursorObject = this.getPaginationData(subGroupId ?? groupId); + const cursorObject = this.getPaginationData(groupId, subGroupId); if (!this.paginationOptions || (cursorObject && !cursorObject?.nextPageResults)) return; try { this.loader = "pagination"; diff --git a/web/store/issue/project-views/issue.store.ts b/web/store/issue/project-views/issue.store.ts index d1cd34672..efac428ba 100644 --- a/web/store/issue/project-views/issue.store.ts +++ b/web/store/issue/project-views/issue.store.ts @@ -79,7 +79,7 @@ export class ProjectViewIssues extends BaseIssuesStore implements IProjectViewIs }; fetchNextIssues = async (workspaceSlug: string, projectId: string, groupId?: string, subGroupId?: string) => { - const cursorObject = this.getPaginationData(subGroupId ?? groupId); + const cursorObject = this.getPaginationData(groupId, subGroupId); if (!this.paginationOptions || (cursorObject && !cursorObject?.nextPageResults)) return; try { this.loader = "pagination"; diff --git a/web/store/issue/project/issue.store.ts b/web/store/issue/project/issue.store.ts index 0271e3297..36ce46a09 100644 --- a/web/store/issue/project/issue.store.ts +++ b/web/store/issue/project/issue.store.ts @@ -82,7 +82,7 @@ export class ProjectIssues extends BaseIssuesStore implements IProjectIssues { }; fetchNextIssues = async (workspaceSlug: string, projectId: string, groupId?: string, subGroupId?: string) => { - const cursorObject = this.getPaginationData(subGroupId ?? groupId); + const cursorObject = this.getPaginationData(groupId, subGroupId); if (!this.paginationOptions || (cursorObject && !cursorObject?.nextPageResults)) return; try { this.loader = "pagination"; diff --git a/web/store/issue/workspace/issue.store.ts b/web/store/issue/workspace/issue.store.ts index 317993d1f..26631d892 100644 --- a/web/store/issue/workspace/issue.store.ts +++ b/web/store/issue/workspace/issue.store.ts @@ -81,7 +81,7 @@ export class WorkspaceIssues extends BaseIssuesStore implements IWorkspaceIssues }; fetchNextIssues = async (workspaceSlug: string, viewId: string, groupId?: string, subGroupId?: string) => { - const cursorObject = this.getPaginationData(subGroupId ?? groupId); + const cursorObject = this.getPaginationData(groupId, subGroupId); if (!this.paginationOptions || (cursorObject && !cursorObject?.nextPageResults)) return; try { this.loader = "pagination";