chore: remove active ids from the MobX stores if not present in the route (#2681)

* chore: remove active ids if not present in the route

* refactor: set active id logic
This commit is contained in:
Aaryan Khandelwal 2023-11-08 17:35:45 +05:30 committed by GitHub
parent df8bdfd5b9
commit 83e0c4ebbd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 21 additions and 20 deletions

View File

@ -62,12 +62,13 @@ const MobxStoreInit = observer(() => {
*/
useEffect(() => {
if (workspaceSlug) setWorkspaceSlug(workspaceSlug.toString());
if (projectId) setProjectId(projectId.toString());
if (cycleId) setCycleId(cycleId.toString());
if (moduleId) setModuleId(moduleId.toString());
if (globalViewId) setGlobalViewId(globalViewId.toString());
if (viewId) setViewId(viewId.toString());
if (inboxId) setInboxId(inboxId.toString());
setProjectId(projectId?.toString() ?? null);
setCycleId(cycleId?.toString() ?? null);
setModuleId(moduleId?.toString() ?? null);
setGlobalViewId(globalViewId?.toString() ?? null);
setViewId(viewId?.toString() ?? null);
setInboxId(inboxId?.toString() ?? null);
}, [
workspaceSlug,
projectId,

View File

@ -32,7 +32,7 @@ export interface ICycleStore {
// actions
setCycleView: (_cycleView: TCycleView) => void;
setCycleLayout: (_cycleLayout: TCycleLayout) => void;
setCycleId: (cycleId: string) => void;
setCycleId: (cycleId: string | null) => void;
validateDate: (workspaceSlug: string, projectId: string, payload: CycleDateCheckData) => Promise<any>;
@ -131,7 +131,7 @@ export class CycleStore implements ICycleStore {
// actions
setCycleView = (_cycleView: TCycleView) => (this.cycleView = _cycleView);
setCycleLayout = (_cycleLayout: TCycleLayout) => (this.cycleLayout = _cycleLayout);
setCycleId = (cycleId: string) => (this.cycleId = cycleId);
setCycleId = (cycleId: string | null) => (this.cycleId = cycleId);
validateDate = async (workspaceSlug: string, projectId: string, payload: CycleDateCheckData) => {
try {

View File

@ -19,7 +19,7 @@ export interface IGlobalViewsStore {
};
// actions
setGlobalViewId: (viewId: string) => void;
setGlobalViewId: (viewId: string | null) => void;
fetchAllGlobalViews: (workspaceSlug: string) => Promise<IWorkspaceView[]>;
fetchGlobalViewDetails: (workspaceSlug: string, viewId: string) => Promise<IWorkspaceView>;
@ -72,7 +72,7 @@ export class GlobalViewsStore implements IGlobalViewsStore {
this.workspaceService = new WorkspaceService();
}
setGlobalViewId = (viewId: string) => {
setGlobalViewId = (viewId: string | null) => {
this.globalViewId = viewId;
};

View File

@ -22,7 +22,7 @@ export interface IInboxStore {
};
// actions
setInboxId: (inboxId: string) => void;
setInboxId: (inboxId: string | null) => void;
getInboxId: (projectId: string) => string | null;
@ -100,7 +100,7 @@ export class InboxStore implements IInboxStore {
return this.inboxesList[projectId]?.[0]?.id ?? null;
};
setInboxId = (inboxId: string) => {
setInboxId = (inboxId: string | null) => {
runInAction(() => {
this.inboxId = inboxId;
});

View File

@ -34,7 +34,7 @@ export interface IModuleStore {
};
// actions
setModuleId: (moduleSlug: string) => void;
setModuleId: (moduleId: string | null) => void;
getModuleById: (moduleId: string) => IModule | null;
@ -144,8 +144,8 @@ export class ModuleStore implements IModuleStore {
getModuleById = (moduleId: string) => this.moduleDetails[moduleId] || null;
// actions
setModuleId = (moduleSlug: string) => {
this.moduleId = moduleSlug ?? null;
setModuleId = (moduleId: string | null) => {
this.moduleId = moduleId;
};
fetchModules = async (workspaceSlug: string, projectId: string) => {

View File

@ -20,7 +20,7 @@ export interface IProjectViewsStore {
};
// actions
setViewId: (viewId: string) => void;
setViewId: (viewId: string | null) => void;
fetchAllViews: (workspaceSlug: string, projectId: string) => Promise<IProjectView[]>;
fetchViewDetails: (workspaceSlug: string, projectId: string, viewId: string) => Promise<IProjectView>;
@ -82,7 +82,7 @@ export class ProjectViewsStore implements IProjectViewsStore {
this.viewService = new ViewService();
}
setViewId = (viewId: string) => {
setViewId = (viewId: string | null) => {
this.viewId = viewId;
};

View File

@ -44,7 +44,7 @@ export interface IProjectStore {
currentProjectDetails: IProject | undefined;
// actions
setProjectId: (projectId: string) => void;
setProjectId: (projectId: string | null) => void;
setSearchQuery: (query: string) => void;
getProjectById: (workspaceSlug: string, projectId: string) => IProject | null;
@ -251,8 +251,8 @@ export class ProjectStore implements IProjectStore {
}
// actions
setProjectId = (projectId: string) => {
this.projectId = projectId ?? null;
setProjectId = (projectId: string | null) => {
this.projectId = projectId;
};
setSearchQuery = (query: string) => {