Skip to content

Commit a99bee7

Browse files
Fix for os users (#16)
* Fix for os users * Fix cancreate org
1 parent ac4a0cf commit a99bee7

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

src/components/projects/ProjectsList.tsx

+5-4
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@ export default function ProjectsList() {
5353
}, []);
5454

5555
useEffect(() => {
56-
if (organizationInactive == null) return;
56+
if (organizationInactive == null || !user) return;
5757
if (!organizationInactive) {
5858
refetchProjectsAndPostProcess();
5959
refetchStatsAndPostProcess();
6060
} else {
6161
createDefaultOrg();
6262
}
63-
}, [organizationInactive]);
63+
}, [organizationInactive, user]);
6464

6565
function refetchProjectsAndPostProcess() {
6666
refetchProjects().then((res) => {
@@ -91,8 +91,9 @@ export default function ProjectsList() {
9191
return;
9292
}
9393
refetchCanCreateOrg().then((res) => {
94-
setCanCreateOrg(res.data["canCreateLocalOrg"]);
95-
if (!canCreateOrg) return;
94+
const canCreate = res.data["canCreateLocalOrg"]
95+
setCanCreateOrg(canCreate);
96+
if (!canCreate) return;
9697
const localhostOrg = "localhost";
9798
createOrgMut({ variables: { name: localhostOrg } }).then((res) => {
9899
addUserToOrgMut({ variables: { userMail: user.mail, organizationName: localhostOrg } }).then((res) => {

src/reduxStore/StoreManagerComponent.tsx

+8-3
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ export function GlobalStoreDataComponent(props: React.PropsWithChildren) {
5858
userInfo.avatarUri = getUserAvatarUri(res.data["userInfo"]);
5959
dispatch(setUser(userInfo));
6060
dispatch(setDisplayUserRole(res.data["userInfo"].role));
61+
6162
});
6263
refetchOrganization().then((res) => {
6364
if (res.data["userOrganization"]) {
@@ -71,9 +72,6 @@ export function GlobalStoreDataComponent(props: React.PropsWithChildren) {
7172
timer(60000).subscribe(() => location.reload())
7273
}
7374
});
74-
refetchOrganizationUsers().then((res) => {
75-
dispatch(setAllUsers(res.data["allUsers"]));
76-
});
7775

7876
// Set cache
7977
refetchZeroShotRecommendations().then((resZeroShot) => {
@@ -90,6 +88,13 @@ export function GlobalStoreDataComponent(props: React.PropsWithChildren) {
9088
});
9189
}, []);
9290

91+
useEffect(() => {
92+
if (!organization) return;
93+
refetchOrganizationUsers().then((res) => {
94+
dispatch(setAllUsers(res.data["allUsers"]));
95+
});
96+
}, [organization]);
97+
9398
useEffect(() => {
9499
const routeColor = RouteManager.checkRouteHighlight(router.asPath);
95100
dispatch(setRouteColor(routeColor));

0 commit comments

Comments
 (0)