From 38c8e50a0e87d01c5b024d1fa62068bd949d55ed Mon Sep 17 00:00:00 2001 From: Pier Francesco Ferrari Date: Thu, 17 Aug 2023 16:41:18 +0200 Subject: [PATCH] fix: avoid useless api requests in ResourceTags --- .../src/ui/resources/ResourceTags.tsx | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/packages/app-elements/src/ui/resources/ResourceTags.tsx b/packages/app-elements/src/ui/resources/ResourceTags.tsx index b065a85a5..c384d9dcb 100644 --- a/packages/app-elements/src/ui/resources/ResourceTags.tsx +++ b/packages/app-elements/src/ui/resources/ResourceTags.tsx @@ -59,13 +59,6 @@ export const ResourceTags = withSkeletonTemplate<{ ] ) - const { data: organizationTags } = useCoreApi('tags', 'list', [ - { - fields: ['id', 'name'], - sort: ['updated_at'], - pageSize: 10 - } - ]) const { sdkClient } = useCoreSdkProvider() const tagsToSelectOptions = useCallback( @@ -93,7 +86,7 @@ export const ResourceTags = withSkeletonTemplate<{ tagsToSelectOptions(resourceTags ?? []) ) - if (resourceTags == null || organizationTags == null) return <> + if (resourceTags == null) return <> return (
@@ -189,9 +182,12 @@ export const ResourceTags = withSkeletonTemplate<{ isClearable={false} isOptionDisabled={() => selectedTags.length >= 10} loadAsyncValues={async (hint) => { - return await sdkClient.tags - .list(makeTagQuery(hint)) - .then(tagsToSelectOptions) + if (hint.length > 0) { + return await sdkClient.tags + .list(makeTagQuery(hint)) + .then(tagsToSelectOptions) + } + return [] }} initialValues={[]} defaultValue={tagsToSelectOptions(resourceTags)}