[WEB-2443] fix: join project flicker (#5602)
* fix: join project flicker * fix: leave project project mutation and code refactor
This commit is contained in:
parent
c14d20c2e0
commit
5ba1eeaf4c
2 changed files with 9 additions and 7 deletions
|
|
@ -105,12 +105,12 @@ export const ProjectAuthWrapper: FC<IProjectAuthWrapper> = observer((props) => {
|
||||||
|
|
||||||
// derived values
|
// derived values
|
||||||
const projectExists = projectId ? getProjectById(projectId.toString()) : null;
|
const projectExists = projectId ? getProjectById(projectId.toString()) : null;
|
||||||
const hasPermissionToCurrentProject = projectId
|
const hasPermissionToCurrentProject = allowPermissions(
|
||||||
? allowPermissions(
|
|
||||||
[EUserPermissions.ADMIN, EUserPermissions.MEMBER, EUserPermissions.GUEST],
|
[EUserPermissions.ADMIN, EUserPermissions.MEMBER, EUserPermissions.GUEST],
|
||||||
EUserPermissionsLevel.PROJECT
|
EUserPermissionsLevel.PROJECT,
|
||||||
)
|
workspaceSlug.toString(),
|
||||||
: undefined;
|
projectId.toString()
|
||||||
|
);
|
||||||
|
|
||||||
// check if the project member apis is loading
|
// check if the project member apis is loading
|
||||||
if (!projectMemberInfo && projectId && hasPermissionToCurrentProject === null)
|
if (!projectMemberInfo && projectId && hasPermissionToCurrentProject === null)
|
||||||
|
|
|
||||||
|
|
@ -243,9 +243,10 @@ export class UserPermissionStore implements IUserPermissionStore {
|
||||||
joinProject = async (workspaceSlug: string, projectId: string): Promise<void | undefined> => {
|
joinProject = async (workspaceSlug: string, projectId: string): Promise<void | undefined> => {
|
||||||
try {
|
try {
|
||||||
const response = await userService.joinProject(workspaceSlug, [projectId]);
|
const response = await userService.joinProject(workspaceSlug, [projectId]);
|
||||||
|
const projectMemberRole = this.workspaceInfoBySlug(workspaceSlug)?.role ?? EUserPermissions.MEMBER;
|
||||||
if (response) {
|
if (response) {
|
||||||
runInAction(() => {
|
runInAction(() => {
|
||||||
set(this.workspaceProjectsPermissions, [workspaceSlug, projectId], response);
|
set(this.workspaceProjectsPermissions, [workspaceSlug, projectId], projectMemberRole);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return response;
|
return response;
|
||||||
|
|
@ -267,6 +268,7 @@ export class UserPermissionStore implements IUserPermissionStore {
|
||||||
runInAction(() => {
|
runInAction(() => {
|
||||||
unset(this.workspaceProjectsPermissions, [workspaceSlug, projectId]);
|
unset(this.workspaceProjectsPermissions, [workspaceSlug, projectId]);
|
||||||
unset(this.projectUserInfo, [workspaceSlug, projectId]);
|
unset(this.projectUserInfo, [workspaceSlug, projectId]);
|
||||||
|
unset(this.store.projectRoot.project.projectMap, [projectId]);
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error user leaving the project", error);
|
console.error("Error user leaving the project", error);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue