fix(ui): fix useGetUserGroupUrns when user urn is empty (#13359)

This commit is contained in:
Felix Lüdin 2025-05-15 05:11:55 +02:00 committed by GitHub
parent 44efca3961
commit a00e65cd2f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 8 additions and 8 deletions

View File

@ -2,10 +2,11 @@ import { useGetUserGroupsUrnsQuery } from '@src/graphql/user.generated';
const NUM_GROUP_URNS_TO_FETCH = 100;
export default function useGetUserGroupUrns(userUrn: string) {
export default function useGetUserGroupUrns(userUrn?: string) {
const { data, loading } = useGetUserGroupsUrnsQuery({
variables: { urn: userUrn, start: 0, count: NUM_GROUP_URNS_TO_FETCH },
variables: { urn: userUrn || '', start: 0, count: NUM_GROUP_URNS_TO_FETCH },
fetchPolicy: 'cache-first',
skip: !userUrn,
});
const groupUrns: string[] =

View File

@ -18,7 +18,7 @@ export const AssetsYouOwn = ({ hideIfEmpty, trackClickInSection }: ReferenceSect
const { user } = userContext;
const [entityCount, setEntityCount] = useState(DEFAULT_MAX_ENTITIES_TO_SHOW);
const [showModal, setShowModal] = useState(false);
const { groupUrns } = useGetUserGroupUrns(user?.urn || '');
const { groupUrns } = useGetUserGroupUrns(user?.urn);
const { entities, loading } = useGetAssetsYouOwn(user);
if (hideIfEmpty && entities.length === 0) {

View File

@ -8,8 +8,7 @@ import { CorpUser } from '@types';
const MAX_ASSETS_TO_FETCH = 50;
export const useGetAssetsYouOwn = (user?: CorpUser | null, count = MAX_ASSETS_TO_FETCH) => {
const userUrn = user?.urn || '';
const { groupUrns, loading: groupDataLoading } = useGetUserGroupUrns(userUrn);
const { groupUrns, loading: groupDataLoading } = useGetUserGroupUrns(user?.urn);
const { loading, data, error } = useGetSearchResultsForMultipleQuery({
variables: {
@ -21,8 +20,8 @@ export const useGetAssetsYouOwn = (user?: CorpUser | null, count = MAX_ASSETS_TO
filters: [
{
field: OWNERS_FILTER_NAME,
value: userUrn,
values: [userUrn, ...groupUrns],
value: user?.urn,
values: [user?.urn || '', ...groupUrns],
},
],
searchFlags: {
@ -30,7 +29,7 @@ export const useGetAssetsYouOwn = (user?: CorpUser | null, count = MAX_ASSETS_TO
},
},
},
skip: !userUrn || groupDataLoading,
skip: !user?.urn || groupDataLoading,
fetchPolicy: 'cache-first',
});