Skip to content

[dashboard] Still render in face of failing listTeams #16941

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions components/dashboard/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,11 @@ const App: FunctionComponent = () => {
if (!user) {
return <Login />;
}
if (currentOrgQuery.isLoading) {
return <AppLoading />;
}
// TODO(gpl) "isLoading" is "true" even if there are errors in this "useCurrentOrg" call.
// Why don't understand as to why .isLoading is not resolved at some point, though. Maybe we're missing proper error handling for useOrganizations
// if (currentOrgQuery.isLoading) {
// return <AppLoading />;
// }

// If we made it here, we have a logged in user w/ their teams. Yay.
return (
Expand Down
8 changes: 8 additions & 0 deletions components/dashboard/src/data/organizations/orgs-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ export function useOrganizations() {
getQueryKey(user),
async () => {
console.log("Fetching orgs... " + JSON.stringify(getQueryKey(user)));
if (!user) {
console.log("useOrganizations with empty user");
return [];
}

const response = await teamsService.listTeams({});
const result: OrganizationInfo[] = [];
for (const org of response.teams) {
Expand All @@ -64,6 +69,9 @@ export function useOrganizations() {
refreshUserBillingMode();
queryClient.invalidateQueries(getUserBillingModeQueryKey(user.id));
},
onError: (err) => {
console.error("useOrganizations", err);
},
enabled: !!user,
cacheTime: 1000 * 60 * 60 * 1, // 1 hour
staleTime: 1000 * 60 * 60 * 1, // 1 hour
Expand Down