Skip to content

Commit d044388

Browse files
committed
[dashboard] don't invalidate useOrganizations on update of user settings
1 parent 0152b84 commit d044388

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
* See License.AGPL.txt in the project root for license information.
55
*/
66

7-
import { User } from "@gitpod/gitpod-protocol";
87
import { useQuery, useQueryClient } from "@tanstack/react-query";
98
import { useCallback } from "react";
109
import { useLocation } from "react-router";
@@ -15,19 +14,20 @@ import { Organization } from "@gitpod/public-api/lib/gitpod/v1/organization_pb";
1514

1615
export function useOrganizationsInvalidator() {
1716
const user = useCurrentUser();
17+
1818
const queryClient = useQueryClient();
1919
return useCallback(() => {
20-
console.log("Invalidating orgs... " + JSON.stringify(getQueryKey(user)));
21-
queryClient.invalidateQueries(getQueryKey(user));
22-
}, [user, queryClient]);
20+
console.log("Invalidating orgs... " + JSON.stringify(getQueryKey(user?.id)));
21+
queryClient.invalidateQueries(getQueryKey(user?.id));
22+
}, [user?.id, queryClient]);
2323
}
2424

2525
export function useOrganizations() {
2626
const user = useCurrentUser();
2727
const query = useQuery<Organization[], Error>(
28-
getQueryKey(user),
28+
getQueryKey(user?.id),
2929
async () => {
30-
console.log("Fetching orgs... " + JSON.stringify(getQueryKey(user)));
30+
console.log("Fetching orgs... " + JSON.stringify(getQueryKey(user?.id)));
3131
if (!user) {
3232
console.log("useOrganizations with empty user");
3333
return [];
@@ -47,8 +47,8 @@ export function useOrganizations() {
4747
return query;
4848
}
4949

50-
function getQueryKey(user?: User) {
51-
return noPersistence(["organizations", user?.id]);
50+
function getQueryKey(userId?: string) {
51+
return noPersistence(["organizations", userId]);
5252
}
5353

5454
// Custom hook to return the current org if one is selected

0 commit comments

Comments
 (0)