Skip to content

Commit

Permalink
chore: issue filter loader improvement (#3406)
Browse files Browse the repository at this point in the history
  • Loading branch information
anmolsinghbhatia authored and sriramveeraghanta committed Jan 22, 2024
1 parent 715002f commit 95b40ee
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 11 deletions.
11 changes: 9 additions & 2 deletions web/store/issue/archived/filter.store.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { action, computed, makeObservable, observable, runInAction } from "mobx";
import isEmpty from "lodash/isEmpty";
import set from "lodash/set";
import pickBy from "lodash/pickBy";
import isArray from "lodash/isArray";
// base class
import { IssueFilterHelperStore } from "../helpers/issue-filter-helper.store";
// helpers
Expand Down Expand Up @@ -148,8 +150,13 @@ export class ArchivedIssuesFilter extends IssueFilterHelperStore implements IArc
set(this.filters, [projectId, "filters", _key], updatedFilters[_key as keyof IIssueFilterOptions]);
});
});

this.rootIssueStore.archivedIssues.fetchIssues(workspaceSlug, projectId, "mutation");
const appliedFilters = _filters.filters || {};
const filteredFilters = pickBy(appliedFilters, (value) => value && isArray(value) && value.length > 0);
this.rootIssueStore.archivedIssues.fetchIssues(
workspaceSlug,
projectId,
isEmpty(filteredFilters) ? "init-loader" : "mutation"
);
this.handleIssuesLocalFilters.set(EIssuesStoreType.ARCHIVED, type, workspaceSlug, projectId, undefined, {
filters: _filters.filters,
});
Expand Down
11 changes: 10 additions & 1 deletion web/store/issue/cycle/filter.store.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { action, computed, makeObservable, observable, runInAction } from "mobx";
import isEmpty from "lodash/isEmpty";
import set from "lodash/set";
import pickBy from "lodash/pickBy";
import isArray from "lodash/isArray";
// base class
import { IssueFilterHelperStore } from "../helpers/issue-filter-helper.store";
// helpers
Expand Down Expand Up @@ -158,7 +160,14 @@ export class CycleIssuesFilter extends IssueFilterHelperStore implements ICycleI
});
});

this.rootIssueStore.cycleIssues.fetchIssues(workspaceSlug, projectId, "mutation", cycleId);
const appliedFilters = _filters.filters || {};
const filteredFilters = pickBy(appliedFilters, (value) => value && isArray(value) && value.length > 0);
this.rootIssueStore.cycleIssues.fetchIssues(
workspaceSlug,
projectId,
isEmpty(filteredFilters) ? "init-loader" : "mutation",
cycleId
);
await this.issueFilterService.patchCycleIssueFilters(workspaceSlug, projectId, cycleId, {
filters: _filters.filters,
});
Expand Down
11 changes: 9 additions & 2 deletions web/store/issue/draft/filter.store.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { action, computed, makeObservable, observable, runInAction } from "mobx";
import isEmpty from "lodash/isEmpty";
import set from "lodash/set";
import pickBy from "lodash/pickBy";
import isArray from "lodash/isArray";
// base class
import { IssueFilterHelperStore } from "../helpers/issue-filter-helper.store";
// helpers
Expand Down Expand Up @@ -143,8 +145,13 @@ export class DraftIssuesFilter extends IssueFilterHelperStore implements IDraftI
set(this.filters, [projectId, "filters", _key], updatedFilters[_key as keyof IIssueFilterOptions]);
});
});

this.rootIssueStore.draftIssues.fetchIssues(workspaceSlug, projectId, "mutation");
const appliedFilters = _filters.filters || {};
const filteredFilters = pickBy(appliedFilters, (value) => value && isArray(value) && value.length > 0);
this.rootIssueStore.draftIssues.fetchIssues(
workspaceSlug,
projectId,
isEmpty(filteredFilters) ? "init-loader" : "mutation"
);
this.handleIssuesLocalFilters.set(EIssuesStoreType.DRAFT, type, workspaceSlug, projectId, undefined, {
filters: _filters.filters,
});
Expand Down
12 changes: 10 additions & 2 deletions web/store/issue/module/filter.store.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { action, computed, makeObservable, observable, runInAction } from "mobx";
import isEmpty from "lodash/isEmpty";
import set from "lodash/set";
import pickBy from "lodash/pickBy";
import isArray from "lodash/isArray";
// base class
import { IssueFilterHelperStore } from "../helpers/issue-filter-helper.store";
// helpers
Expand Down Expand Up @@ -157,8 +159,14 @@ export class ModuleIssuesFilter extends IssueFilterHelperStore implements IModul
set(this.filters, [moduleId, "filters", _key], updatedFilters[_key as keyof IIssueFilterOptions]);
});
});

this.rootIssueStore.moduleIssues.fetchIssues(workspaceSlug, projectId, "mutation", moduleId);
const appliedFilters = _filters.filters || {};
const filteredFilters = pickBy(appliedFilters, (value) => value && isArray(value) && value.length > 0);
this.rootIssueStore.moduleIssues.fetchIssues(
workspaceSlug,
projectId,
isEmpty(filteredFilters) ? "init-loader" : "mutation",
moduleId
);
await this.issueFilterService.patchModuleIssueFilters(workspaceSlug, projectId, moduleId, {
filters: _filters.filters,
});
Expand Down
7 changes: 6 additions & 1 deletion web/store/issue/profile/filter.store.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { action, computed, makeObservable, observable, runInAction } from "mobx";
import isEmpty from "lodash/isEmpty";
import set from "lodash/set";
import pickBy from "lodash/pickBy";
import isArray from "lodash/isArray";
// base class
import { IssueFilterHelperStore } from "../helpers/issue-filter-helper.store";
// helpers
Expand Down Expand Up @@ -150,13 +152,16 @@ export class ProfileIssuesFilter extends IssueFilterHelperStore implements IProf
});
});

const appliedFilters = _filters.filters || {};
const filteredFilters = pickBy(appliedFilters, (value) => value && isArray(value) && value.length > 0);
this.rootIssueStore.profileIssues.fetchIssues(
workspaceSlug,
undefined,
"mutation",
isEmpty(filteredFilters) ? "init-loader" : "mutation",
userId,
this.rootIssueStore.profileIssues.currentView
);

this.handleIssuesLocalFilters.set(EIssuesStoreType.PROFILE, type, workspaceSlug, userId, undefined, {
filters: _filters.filters,
});
Expand Down
11 changes: 10 additions & 1 deletion web/store/issue/project-views/filter.store.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { action, computed, makeObservable, observable, runInAction } from "mobx";
import isEmpty from "lodash/isEmpty";
import set from "lodash/set";
import pickBy from "lodash/pickBy";
import isArray from "lodash/isArray";
// base class
import { IssueFilterHelperStore } from "../helpers/issue-filter-helper.store";
// helpers
Expand Down Expand Up @@ -159,7 +161,14 @@ export class ProjectViewIssuesFilter extends IssueFilterHelperStore implements I
});
});

this.rootIssueStore.projectViewIssues.fetchIssues(workspaceSlug, projectId, "mutation", viewId);
const appliedFilters = _filters.filters || {};
const filteredFilters = pickBy(appliedFilters, (value) => value && isArray(value) && value.length > 0);
this.rootIssueStore.projectViewIssues.fetchIssues(
workspaceSlug,
projectId,
isEmpty(filteredFilters) ? "init-loader" : "mutation",
viewId
);
break;
case EIssueFilterType.DISPLAY_FILTERS:
const updatedDisplayFilters = filters as IIssueDisplayFilterOptions;
Expand Down
10 changes: 9 additions & 1 deletion web/store/issue/project/filter.store.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { action, computed, makeObservable, observable, runInAction } from "mobx";
import isEmpty from "lodash/isEmpty";
import set from "lodash/set";
import pickBy from "lodash/pickBy";
import isArray from "lodash/isArray";
// base class
import { IssueFilterHelperStore } from "../helpers/issue-filter-helper.store";
// helpers
Expand Down Expand Up @@ -155,7 +157,13 @@ export class ProjectIssuesFilter extends IssueFilterHelperStore implements IProj
});
});

this.rootIssueStore.projectIssues.fetchIssues(workspaceSlug, projectId, "mutation");
const appliedFilters = _filters.filters || {};
const filteredFilters = pickBy(appliedFilters, (value) => value && isArray(value) && value.length > 0);
this.rootIssueStore.projectIssues.fetchIssues(
workspaceSlug,
projectId,
isEmpty(filteredFilters) ? "init-loader" : "mutation"
);
await this.issueFilterService.patchProjectIssueFilters(workspaceSlug, projectId, {
filters: _filters.filters,
});
Expand Down
10 changes: 9 additions & 1 deletion web/store/issue/workspace/filter.store.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { action, computed, makeObservable, observable, runInAction } from "mobx";
import isEmpty from "lodash/isEmpty";
import set from "lodash/set";
import pickBy from "lodash/pickBy";
import isArray from "lodash/isArray";
// base class
import { IssueFilterHelperStore } from "../helpers/issue-filter-helper.store";
// helpers
Expand Down Expand Up @@ -180,7 +182,13 @@ export class WorkspaceIssuesFilter extends IssueFilterHelperStore implements IWo
set(this.filters, [viewId, "filters", _key], updatedFilters[_key as keyof IIssueFilterOptions]);
});
});
this.rootIssueStore.workspaceIssues.fetchIssues(workspaceSlug, viewId, "mutation");
const appliedFilters = _filters.filters || {};
const filteredFilters = pickBy(appliedFilters, (value) => value && isArray(value) && value.length > 0);
this.rootIssueStore.workspaceIssues.fetchIssues(
workspaceSlug,
viewId,
isEmpty(filteredFilters) ? "init-loader" : "mutation"
);
break;
case EIssueFilterType.DISPLAY_FILTERS:
const updatedDisplayFilters = filters as IIssueDisplayFilterOptions;
Expand Down

0 comments on commit 95b40ee

Please sign in to comment.