Skip to content

armgit / plane

Public Imported from GitHub
0

πŸ”₯πŸ”₯πŸ”₯ Open-source Jira, Linear, Monday, and ClickUp alternative. Plane is a modern project management platform to manage tasks, sprints, docs, and triage.

fix: project, module, cycle filter store infinite loop (#3994)

Lakhan Baheti901a7703ff20
diff --git a/web/store/cycle_filter.store.ts b/web/store/cycle_filter.store.ts
index b610741b9d..2c57b5e782 100644
--- a/web/store/cycle_filter.store.ts
+++ b/web/store/cycle_filter.store.ts
@@ -1,4 +1,4 @@
-import { action, computed, observable, makeObservable, runInAction, autorun } from "mobx";
+import { action, computed, observable, makeObservable, runInAction, reaction } from "mobx";
import { computedFn } from "mobx-utils";
import set from "lodash/set";
// types
@@ -49,11 +49,13 @@ export class CycleFilterStore implements ICycleFilterStore {
// root store
this.rootStore = _rootStore;
// initialize display filters of the current project
- autorun(() => {
- const projectId = this.rootStore.app.router.projectId;
- if (!projectId) return;
- this.initProjectCycleFilters(projectId);
- });
+ reaction(
+ () => this.rootStore.app.router.projectId,
+ (projectId) => {
+ if (!projectId) return;
+ this.initProjectCycleFilters(projectId);
+ }
+ );
}
/**
@@ -97,7 +99,7 @@ export class CycleFilterStore implements ICycleFilterStore {
active_tab: displayFilters?.active_tab || "active",
layout: displayFilters?.layout || "list",
};
- this.filters[projectId] = {};
+ this.filters[projectId] = this.filters[projectId] ?? {};
});
};
diff --git a/web/store/module_filter.store.ts b/web/store/module_filter.store.ts
index 7ead79e7e0..ae5d071351 100644
--- a/web/store/module_filter.store.ts
+++ b/web/store/module_filter.store.ts
@@ -1,4 +1,4 @@
-import { action, computed, observable, makeObservable, runInAction, autorun } from "mobx";
+import { action, computed, observable, makeObservable, runInAction, reaction } from "mobx";
import { computedFn } from "mobx-utils";
import set from "lodash/set";
// types
@@ -49,11 +49,13 @@ export class ModuleFilterStore implements IModuleFilterStore {
// root store
this.rootStore = _rootStore;
// initialize display filters of the current project
- autorun(() => {
- const projectId = this.rootStore.app.router.projectId;
- if (!projectId) return;
- this.initProjectModuleFilters(projectId);
- });
+ reaction(
+ () => this.rootStore.app.router.projectId,
+ (projectId) => {
+ if (!projectId) return;
+ this.initProjectModuleFilters(projectId);
+ }
+ );
}
/**
@@ -98,7 +100,7 @@ export class ModuleFilterStore implements IModuleFilterStore {
layout: displayFilters?.layout || "list",
order_by: displayFilters?.order_by || "name",
};
- this.filters[projectId] = {};
+ this.filters[projectId] = this.filters[projectId] ?? {};
});
};
diff --git a/web/store/project/project_filter.store.ts b/web/store/project/project_filter.store.ts
index 013f2dff57..7d6aff96f5 100644
--- a/web/store/project/project_filter.store.ts
+++ b/web/store/project/project_filter.store.ts
@@ -1,4 +1,4 @@
-import { action, computed, observable, makeObservable, runInAction, autorun } from "mobx";
+import { action, computed, observable, makeObservable, runInAction, reaction } from "mobx";
import { computedFn } from "mobx-utils";
import set from "lodash/set";
// types
@@ -49,11 +49,13 @@ export class ProjectFilterStore implements IProjectFilterStore {
// root store
this.rootStore = _rootStore;
// initialize display filters of the current workspace
- autorun(() => {
- const workspaceSlug = this.rootStore.app.router.workspaceSlug;
- if (!workspaceSlug) return;
- this.initWorkspaceFilters(workspaceSlug);
- });
+ reaction(
+ () => this.rootStore.app.router.workspaceSlug,
+ (workspaceSlug) => {
+ if (!workspaceSlug) return;
+ this.initWorkspaceFilters(workspaceSlug);
+ }
+ );
}
/**
@@ -96,7 +98,7 @@ export class ProjectFilterStore implements IProjectFilterStore {
this.displayFilters[workspaceSlug] = {
order_by: displayFilters?.order_by || "created_at",
};
- this.filters[workspaceSlug] = {};
+ this.filters[workspaceSlug] = this.filters[workspaceSlug] ?? {};
});
};