From 5b808571e5d614814d5a3c5d01770582d3a08241 Mon Sep 17 00:00:00 2001 From: Dakshesh Jain <65905942+dakshesh14@users.noreply.github.com> Date: Thu, 2 Nov 2023 16:26:16 +0530 Subject: [PATCH] fix: exception error (#2606) * fix: exception error * fix: invitation type --- web/components/project/member-list.tsx | 7 ------- web/store/project/project_label_store.ts | 2 +- web/store/project/project_state.store.ts | 10 ++-------- web/store/user.store.ts | 4 ++-- 4 files changed, 5 insertions(+), 18 deletions(-) diff --git a/web/components/project/member-list.tsx b/web/components/project/member-list.tsx index 1dfc87b8f..aea4ccda2 100644 --- a/web/components/project/member-list.tsx +++ b/web/components/project/member-list.tsx @@ -31,13 +31,6 @@ export const ProjectMemberList: React.FC = observer(() => { const { user } = useUser(); - useSWR( - workspaceSlug && projectId ? `PROJECT_MEMBERS_${projectId.toString().toUpperCase()}` : null, - workspaceSlug && projectId - ? () => projectStore.fetchProjectMembers(workspaceSlug.toString(), projectId.toString()) - : null - ); - const { data: projectInvitations } = useSWR( workspaceSlug && projectId ? `PROJECT_INVITATIONS_${projectId.toString()}` : null, workspaceSlug && projectId diff --git a/web/store/project/project_label_store.ts b/web/store/project/project_label_store.ts index 495b8e9f1..f4ea6892a 100644 --- a/web/store/project/project_label_store.ts +++ b/web/store/project/project_label_store.ts @@ -102,7 +102,7 @@ export class ProjectLabelStore implements IProjectLabelStore { [projectId]: (this.rootStore.project.labels?.[projectId] || [])?.map((label) => label.id === labelId ? { ...label, ...originalLabel } : label ), - } as any; + }; }); throw error; } diff --git a/web/store/project/project_state.store.ts b/web/store/project/project_state.store.ts index e5c7732fe..56fc0c203 100644 --- a/web/store/project/project_state.store.ts +++ b/web/store/project/project_state.store.ts @@ -81,7 +81,7 @@ export class ProjectStateStore implements IProjectStateStore { }; updateState = async (workspaceSlug: string, projectId: string, stateId: string, data: Partial) => { - const originalStates = this.rootStore.project.states; + const originalStates = this.rootStore.project.states || {}; runInAction(() => { this.rootStore.project.states = { @@ -120,13 +120,7 @@ export class ProjectStateStore implements IProjectStateStore { } catch (error) { console.log("Failed to update state from project store"); runInAction(() => { - this.rootStore.project.states = { - ...this.rootStore.project.states, - [projectId]: { - ...this.rootStore.project.states?.[projectId], - [data.group as string]: originalStates || [], - }, - } as any; + this.rootStore.project.states = originalStates; }); throw error; } diff --git a/web/store/user.store.ts b/web/store/user.store.ts index 6fb2c08f3..fbb6a4a30 100644 --- a/web/store/user.store.ts +++ b/web/store/user.store.ts @@ -122,7 +122,7 @@ class UserStore implements IUserStore { get currentWorkspaceRole() { if (!this.rootStore.workspace.workspaceSlug) return; - return this.workspaceMemberInfo[this.rootStore.workspace.workspaceSlug].role; + return this.workspaceMemberInfo[this.rootStore.workspace.workspaceSlug]?.role; } get currentProjectMemberInfo() { @@ -132,7 +132,7 @@ class UserStore implements IUserStore { get currentProjectRole() { if (!this.rootStore.project.projectId) return; - return this.projectMemberInfo[this.rootStore.project.projectId].role; + return this.projectMemberInfo[this.rootStore.project.projectId]?.role; } get hasPermissionToCurrentWorkspace() {