mirror of
https://github.com/makeplane/plane.git
synced 2025-12-25 16:19:43 +01:00
[WEB-2443] fix: join project flicker (#5602)
* fix: join project flicker * fix: leave project project mutation and code refactor
This commit is contained in:
committed by
GitHub
parent
c14d20c2e0
commit
5ba1eeaf4c
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user