From 3f9523804b76e66d9332174d60e9e03247bdae30 Mon Sep 17 00:00:00 2001 From: Anmol Singh Bhatia <121005188+anmolsinghbhatia@users.noreply.github.com> Date: Tue, 6 Aug 2024 16:42:13 +0530 Subject: [PATCH] fix: delete action mutation (#5315) --- web/core/store/cycle.store.ts | 2 +- web/core/store/module.store.ts | 2 +- web/core/store/pages/project-page.store.ts | 2 +- web/core/store/project-view.store.ts | 2 +- web/core/store/project/project.store.ts | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/web/core/store/cycle.store.ts b/web/core/store/cycle.store.ts index d8ef84cf6..2845527c2 100644 --- a/web/core/store/cycle.store.ts +++ b/web/core/store/cycle.store.ts @@ -551,9 +551,9 @@ export class CycleStore implements ICycleStore { deleteCycle = async (workspaceSlug: string, projectId: string, cycleId: string) => await this.cycleService.deleteCycle(workspaceSlug, projectId, cycleId).then(() => { runInAction(() => { - this.rootStore.favorite.removeFavoriteFromStore(cycleId); delete this.cycleMap[cycleId]; delete this.activeCycleIdMap[cycleId]; + if (this.rootStore.favorite.entityMap[cycleId]) this.rootStore.favorite.removeFavoriteFromStore(cycleId); }); }); diff --git a/web/core/store/module.store.ts b/web/core/store/module.store.ts index e5631eedf..23e5cb012 100644 --- a/web/core/store/module.store.ts +++ b/web/core/store/module.store.ts @@ -405,7 +405,7 @@ export class ModulesStore implements IModuleStore { await this.moduleService.deleteModule(workspaceSlug, projectId, moduleId).then(() => { runInAction(() => { delete this.moduleMap[moduleId]; - this.rootStore.favorite.removeFavoriteFromStore(moduleId); + if (this.rootStore.favorite.entityMap[moduleId]) this.rootStore.favorite.removeFavoriteFromStore(moduleId); }); }); }; diff --git a/web/core/store/pages/project-page.store.ts b/web/core/store/pages/project-page.store.ts index 18487d3b3..0629cc17b 100644 --- a/web/core/store/pages/project-page.store.ts +++ b/web/core/store/pages/project-page.store.ts @@ -261,7 +261,7 @@ export class ProjectPageStore implements IProjectPageStore { await this.service.remove(workspaceSlug, projectId, pageId); runInAction(() => { unset(this.data, [pageId]); - this.rootStore.favorite.removeFavoriteFromStore(pageId); + if (this.rootStore.favorite.entityMap[pageId]) this.rootStore.favorite.removeFavoriteFromStore(pageId); }); } catch (error) { runInAction(() => { diff --git a/web/core/store/project-view.store.ts b/web/core/store/project-view.store.ts index 61721cad7..b9f4e8656 100644 --- a/web/core/store/project-view.store.ts +++ b/web/core/store/project-view.store.ts @@ -271,7 +271,7 @@ export class ProjectViewStore implements IProjectViewStore { await this.viewService.deleteView(workspaceSlug, projectId, viewId).then(() => { runInAction(() => { delete this.viewMap[viewId]; - this.rootStore.favorite.removeFavoriteFromStore(viewId); + if (this.rootStore.favorite.entityMap[viewId]) this.rootStore.favorite.removeFavoriteFromStore(viewId); }); }); }; diff --git a/web/core/store/project/project.store.ts b/web/core/store/project/project.store.ts index fe1f30566..faebabf15 100644 --- a/web/core/store/project/project.store.ts +++ b/web/core/store/project/project.store.ts @@ -401,7 +401,7 @@ export class ProjectStore implements IProjectStore { await this.projectService.deleteProject(workspaceSlug, projectId); runInAction(() => { delete this.projectMap[projectId]; - this.rootStore.favorite.removeFavoriteFromStore(projectId); + if (this.rootStore.favorite.entityMap[projectId]) this.rootStore.favorite.removeFavoriteFromStore(projectId); }); } catch (error) { console.log("Failed to delete project from project store");