[WEB-2443] fix: join project flicker (#5602)

* fix: join project flicker

* fix: leave project project mutation and code refactor
This commit is contained in:
Anmol Singh Bhatia
2024-09-16 14:16:23 +05:30
committed by GitHub
parent c14d20c2e0
commit 5ba1eeaf4c
2 changed files with 9 additions and 7 deletions

View File

@@ -105,12 +105,12 @@ export const ProjectAuthWrapper: FC<IProjectAuthWrapper> = observer((props) => {
// derived values
const projectExists = projectId ? getProjectById(projectId.toString()) : null;
const hasPermissionToCurrentProject = projectId
? allowPermissions(
[EUserPermissions.ADMIN, EUserPermissions.MEMBER, EUserPermissions.GUEST],
EUserPermissionsLevel.PROJECT
)
: undefined;
const hasPermissionToCurrentProject = allowPermissions(
[EUserPermissions.ADMIN, EUserPermissions.MEMBER, EUserPermissions.GUEST],
EUserPermissionsLevel.PROJECT,
workspaceSlug.toString(),
projectId.toString()
);
// check if the project member apis is loading
if (!projectMemberInfo && projectId && hasPermissionToCurrentProject === null)

View File

@@ -243,9 +243,10 @@ export class UserPermissionStore implements IUserPermissionStore {
joinProject = async (workspaceSlug: string, projectId: string): Promise<void | undefined> => {
try {
const response = await userService.joinProject(workspaceSlug, [projectId]);
const projectMemberRole = this.workspaceInfoBySlug(workspaceSlug)?.role ?? EUserPermissions.MEMBER;
if (response) {
runInAction(() => {
set(this.workspaceProjectsPermissions, [workspaceSlug, projectId], response);
set(this.workspaceProjectsPermissions, [workspaceSlug, projectId], projectMemberRole);
});
}
return response;
@@ -267,6 +268,7 @@ export class UserPermissionStore implements IUserPermissionStore {
runInAction(() => {
unset(this.workspaceProjectsPermissions, [workspaceSlug, projectId]);
unset(this.projectUserInfo, [workspaceSlug, projectId]);
unset(this.store.projectRoot.project.projectMap, [projectId]);
});
} catch (error) {
console.error("Error user leaving the project", error);