Skip to content

Commit f4c173b

Browse files
authored
[dashboard] Still render in face of failing listTeams (#16941)
1 parent ff298a4 commit f4c173b

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

components/dashboard/src/App.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,11 @@ const App: FunctionComponent = () => {
5151
if (!user) {
5252
return <Login />;
5353
}
54-
if (currentOrgQuery.isLoading) {
55-
return <AppLoading />;
56-
}
54+
// TODO(gpl) "isLoading" is "true" even if there are errors in this "useCurrentOrg" call.
55+
// Why don't understand as to why .isLoading is not resolved at some point, though. Maybe we're missing proper error handling for useOrganizations
56+
// if (currentOrgQuery.isLoading) {
57+
// return <AppLoading />;
58+
// }
5759

5860
// If we made it here, we have a logged in user w/ their teams. Yay.
5961
return (

components/dashboard/src/data/organizations/orgs-query.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ export function useOrganizations() {
3939
getQueryKey(user),
4040
async () => {
4141
console.log("Fetching orgs... " + JSON.stringify(getQueryKey(user)));
42+
if (!user) {
43+
console.log("useOrganizations with empty user");
44+
return [];
45+
}
46+
4247
const response = await teamsService.listTeams({});
4348
const result: OrganizationInfo[] = [];
4449
for (const org of response.teams) {
@@ -64,6 +69,9 @@ export function useOrganizations() {
6469
refreshUserBillingMode();
6570
queryClient.invalidateQueries(getUserBillingModeQueryKey(user.id));
6671
},
72+
onError: (err) => {
73+
console.error("useOrganizations", err);
74+
},
6775
enabled: !!user,
6876
cacheTime: 1000 * 60 * 60 * 1, // 1 hour
6977
staleTime: 1000 * 60 * 60 * 1, // 1 hour

0 commit comments

Comments
 (0)