Skip to content

Commit 5ba1eea

Browse files
[WEB-2443] fix: join project flicker (#5602)
* fix: join project flicker * fix: leave project project mutation and code refactor
1 parent c14d20c commit 5ba1eea

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

web/core/layouts/auth-layout/project-wrapper.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,12 @@ export const ProjectAuthWrapper: FC<IProjectAuthWrapper> = observer((props) => {
105105

106106
// derived values
107107
const projectExists = projectId ? getProjectById(projectId.toString()) : null;
108-
const hasPermissionToCurrentProject = projectId
109-
? allowPermissions(
110-
[EUserPermissions.ADMIN, EUserPermissions.MEMBER, EUserPermissions.GUEST],
111-
EUserPermissionsLevel.PROJECT
112-
)
113-
: undefined;
108+
const hasPermissionToCurrentProject = allowPermissions(
109+
[EUserPermissions.ADMIN, EUserPermissions.MEMBER, EUserPermissions.GUEST],
110+
EUserPermissionsLevel.PROJECT,
111+
workspaceSlug.toString(),
112+
projectId.toString()
113+
);
114114

115115
// check if the project member apis is loading
116116
if (!projectMemberInfo && projectId && hasPermissionToCurrentProject === null)

web/core/store/user/permissions.store.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,9 +243,10 @@ export class UserPermissionStore implements IUserPermissionStore {
243243
joinProject = async (workspaceSlug: string, projectId: string): Promise<void | undefined> => {
244244
try {
245245
const response = await userService.joinProject(workspaceSlug, [projectId]);
246+
const projectMemberRole = this.workspaceInfoBySlug(workspaceSlug)?.role ?? EUserPermissions.MEMBER;
246247
if (response) {
247248
runInAction(() => {
248-
set(this.workspaceProjectsPermissions, [workspaceSlug, projectId], response);
249+
set(this.workspaceProjectsPermissions, [workspaceSlug, projectId], projectMemberRole);
249250
});
250251
}
251252
return response;
@@ -267,6 +268,7 @@ export class UserPermissionStore implements IUserPermissionStore {
267268
runInAction(() => {
268269
unset(this.workspaceProjectsPermissions, [workspaceSlug, projectId]);
269270
unset(this.projectUserInfo, [workspaceSlug, projectId]);
271+
unset(this.store.projectRoot.project.projectMap, [projectId]);
270272
});
271273
} catch (error) {
272274
console.error("Error user leaving the project", error);

0 commit comments

Comments
 (0)