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

This commit is contained in:
Lakhan Baheti 2024-03-20 18:06:45 +05:30 committed by GitHub
parent 2f883e4939
commit 901a7703ff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 27 additions and 21 deletions

View File

@ -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;
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] ?? {};
});
};

View File

@ -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;
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] ?? {};
});
};

View File

@ -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;
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] ?? {};
});
};